Rumah > Artikel > pembangunan bahagian belakang > 评价一上,小弟我写的oop
评价一下,我写的oop
谢谢了,就是一个连数据库的类
<?php<br /> class db{<br /> public $conn;<br /> function __construct(){<br /> $this->conn=mysqli_connect('localhost','root','123123','air');<br /> //$this->conn->query('SET NAMES UTF8');<br /> mysqli_query($this->conn,'SET NAMES UTF8');<br /> }<br /> public function delete($table,$condition=""){<br /> if(empty($condition)) {<br /> $this->halt('没有设置删除的条件');<br /> return false;<br /> }<br /> $sql = "delete from ".$table." where 1=1 and ".$condition;<br /> if(!$this->conn->query($sql)){<br /> return false;<br /> }else{<br /> return true;<br /> }//if<br /> }<br /> public function getAll($sql){//输出数组所有<br /> $rt=array();<br /> $q=$this->conn->query($sql);<br /> $this->conn->query('SET NAMES UTF8');<br /> while($r=$q->fetch_array(MYSQLI_USE_RESULT)){<br /> $rt[]=$r;<br /> }<br /> return $rt; <br /> } <br /> public function __destruct(){<br /> mysqli_close($this->conn);<br /> }<br /> }//db<br /> ?>