简单实用MySQL数据库PHP操作类

作者:袖梨 2022-06-24

例子

 代码如下 复制代码

class SqlTool{
private $conn;
private $host=”localhost”;
private $user=”root”;
private $password=”";
private $db=”bbs”;
function sqlTool(){
$this->conn=mysql_connect(“$this->host”,”$this->user”,”$this->password”);
mysql_select_db($this->db,$this->conn);
mysql_query(“set names gbk”);
}
function executedql($sql){
$res=mysql_query($sql);
return $res;
}
function executedml($sql){
$b=mysql_query($sql);
if(!$b){
echo “操作失败”;
}else{
if(mysql_affected_rows($this->conn)>0){
echo “操作成功”;
}else{
echo “没有影响到行数”;
}
}
mysql_close($this->conn);
}
}
?>

相关文章

精彩推荐