<?PHPclasssqltools{Private $con; Private $trans; Public function__construct ($host,$user,$pswd,$db){ $this->con =NewMysqli ($host,$user,$pswd,$db); if($this->con->connect_error) die("CONNECT ERROR:".)$this->con->connect_errno. ":".$this->con->connect_error. " <br/> "); $this->con->query ("Set Names UTF8"); } /*Start Transaction*/ Public functionStart_trans () {$this->con->autocommit (false); $this->trans =true; } /*rollback*/ Public functionrollback () {$this->con->rollback (); } /*Add, insert, update and so on*/ Public functionExecute$sql){ $exec _bool=$this->con->query ($sql); if($exec _bool) die("EXEC ERROR:".)$this->con->errno. ":".$this->con->error. " <br/> "); return $this->con->affected_rows; } /*Select*/ Public function&execute_query ($sql){ $res=$this->con->query ($sql); if(!$res) die("QUERY ERROR:".)$this->con->errno. ":".$this->con->error. " <br/> "); return $res; } /*Free Resource*/ Public functionClose () {if($this-Trans)$this-rollback (); if($this-con)$this->con->Close (); }}
[Php]mysqli Operation Flow