php-based on object-oriented MySQL class

Source: Internet
Author: User

classsqlhelper{Private $conn; Private $host= ' localhost '; Private $user= ' Root '; Private $pwd= ' Root '; Private $db;  Public function__construct ($idb) {$this->db =$idb; $this->conn =NewMysqli ($this->host,$this->user,$this-$this->pwd,$this-IDB); if($this->conn->connect_error) {$this->error ($this->conn->connect_error); }$this->conn->query (' Set names UTF8 '); }  //for SELECT statements   Public functionEXECUTE_DQL ($sql){                   $res=$this->conn->query ($sql) or$this->error (' query operation failed '.$this->conn->error); $this-Free (); return $res; }//for INSERT, UPDATE, Delect Public functionEXECUTE_DML ($sql){                   $flag=$this->conn->query ($sql) or$this->error ($this->conn->error); if(!$flag) {return0;//operation failed}Else{if($this->conn->afffected_rows > 0) {return1;//Operation succeeded}Else{return2;//operation failed with no number of rows affected }}}//for multi-line records Public functionFetch_all ($sql) {$res=$this->conn->query ($sql) or$this->error (' query operation failed '.$this->conn->error); $arr=Array();  while($row=$res-Fetch_assoc ()) {$arr[] =$row;//release resources in a timely manner}return $arr;}protected functionError$err){                    $log= ' Cur.log '; File_put_contens ($log,$err,file_append);  die($err);}} 

php-based on object-oriented MySQL 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.