php实现mysql简易操作类,phpmysql自己封装的mysql简易操作类,已塞在ben框架中,基于pdo来写的,代码风格上有些无厘头。。。
mysql.class.php
server = $server; $this->database = $database; $this->user = $user; $this->password = $password; parent::__construct(mysql:host=$server;port=$port;dbname=$database,$user,$password); $this->query('set names utf8'); } public function drop($table){ $sql = 'drop table '.$table.';'; $re = $this->query($sql); if($re){ return true; }else{ return false; } } public function insert($table,$name,$value=null){ $sql = insert into .$table.'('; if($value == null){ $arrname = array_keys($name); $arrvalue = array_values($name); }else{ $arrname = explode('|', $name); $arrvalue = explode('|', $value); } for($i=0;$ifetch(); return $row[$name]; } public function update($table,$name,$value,$conditionsname,$conditionsvalue=null){ if($conditionsvalue!=null){ $sql = update .$table. set .$name.= '.$value.' where .$conditionsname.='.$conditionsvalue.';; }else{ $sql = update .$table. set .$name.= '.$value.' where ; $arrname = array_keys($conditionsname); $arrvalue = array_values($conditionsname); for($i=0;$iquery($sql); if($re){ return true; }else{ return false; } } public function group($table,$name){ $sql = select .$name. from .$table.;; $return = array(); $re = $this->query($sql); while($row = $re->fetch(pdo::fetch_assoc)){ array_push($return,$row[$name]); } return $return; } public function fetchall($sql){ $return = array(); $re = $this->query($sql); while($row = $re->fetch(pdo::fetch_assoc)){ array_push($return,$row); } return $return; }}
http://www.bkjia.com/phpjc/1060091.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/1060091.htmltecharticlephp实现mysql简易操作类,phpmysql 自己封装的mysql简易操作类,已塞在ben框架中,基于pdo来写的,代码风格上有些无厘头。。。 mysql.class.php...