Home > Backend Development > PHP Tutorial > 一个简单记事本php操作mysql辅助类创建

一个简单记事本php操作mysql辅助类创建

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 13:18:14
Original
1120 people have browsed it

//SqlHelper.class.php<?phpclass SqlHelper{    public $conn;    public $host="localhost";    public $user="root";    public $passwrd="passwd";    public $db="notebook";    function __construct(){        $this->conn=mysql_connect($this->host,$this->user,$this->passwrd);        if(!$this->conn){           die("连接失败".mysql_error());         }        mysql_select_db($this->db);        mysql_query("set names utf8");    }    //增删改    function execute_dml($sql){       $b=mysql_query($sql);       if(!$b){           die("操作失败".mysql_error());       }else if(mysql_affected_rows($this->conn)>0){           return 1;       }else{           return 2;       }    }    //查询,多条结果    function execute_dql($sql){        $arr=array();        $res=mysql_query($sql);        $i=0;        while($row=mysql_fetch_assoc($res)){            $arr[$i++]=$row;        }        mysql_free_result($res);        return $arr;    }    //查询,单条结果    function execute_dql2($sql){        $res=mysql_query($sql);        return $res;    }    function conn_close(){        if(!empty($this->conn)){            mysql_close($this->conn);        }    }  }
Copy after login


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template