PHP database additions and deletions to change the Operation class

Source: Internet
Author: User
Tags php database

1<?PHP2     3     /**4 * Function Name: SqlTool.class.php5 * Function function: PHP to delete the database and change the operation class6 * Function Zhang Zhengui7 * Creation time: 2015-01-058 * Modified time:9     */Ten     Header("Content-type:text/html;charset=utf-8"); One     classsqltool{ A         Private $conn; -         Private $host= ' localhost '; -         Private $root= ' Root '; the         Private $password= ' '; -         Private $dbname=test; -  -         function__construct () { +             #code ... -             $this->conn =mysql_connect($this->host,$this->root,$this->password) or die(' Failed to connect to database '.Mysql_error()); +             mysql_select_db($this-dbname); AMysql_set_charset (' UTF8 '); at         } -  -         /***************************DQL Operation ***********************************/ -          Public functionEXECUTE_DQL ($sql){ -             $res=mysql_query($sql,$this->conn) or die(Mysql_error()); -             return $res; in         } -  to         /****************************dml Operation ***********************************/ +          Public functionEXECUTE_DML ($sql){ -             $res=mysql_query($sql,$this->conn) or die(Mysql_error()); the             if(!$res) { *                 #code ... $                 return0;Panax Notoginseng}ElseIf(mysql_affected_rows($this->conn) > 0) { -                 #code ... the                 return1; +}Else{ A                 #code ... the                 return2; +             } -         } $     } $  - /******************* - $sql = "INSERT INTO User1 (id,name) VALUES (' 7 ', ' Lu Xun ')"; the //Create Objects - $sqlTool = new SqlTool;Wuyi $result = $sqlTool-Execute_dml ($sql); the if ($result = = 0) { - # code ... Wu echo "Failure"; - }elseif ($result = = 1) { About # code ... $ echo "Success"; - }elseif ($result = = 2) { - # code ... - echo "does not affect the number of rows"; A     } + *******************/     the?>

PHP database additions and deletions to change the Operation class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.