例子
代码如下 | 复制代码 |
<?php 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); } } ?> |
时间: 2024-11-29 03:30:01