相关mysql视频教程推荐:《mysql教程》
1.mysqli扩展库操作数据库工具类
conn=new mysqli($this->host, $this->username, $this->password,$this->dbname) or die($this->conn->connect_error); } //查询 public function query($sql){ $all= $this->conn->query($sql); return $all; } //插入,修改,删除 public function otheroperate($sql){ if($this->conn->query($sql)){ if($this->conn->affected_rows>0){ return "ok"; }else{ return "erroor"; } } } public function close(){ $this->conn->close(); } }?>
2.下面是具体的调用工具类的代码
query($sql); while($row=$result->fetch_assoc()){ echo "$row[stuname]".""; } $result->free(); $util->close();*/ $sql="update m_student set stuname='杨幂' where id=3"; $util=new dbutil(); $result=$util->otheroperate($sql); echo $result; $util->close();?>
