PHP头条
热点:

调用-自己写的一个php的PDO的类,有点问题,求大神指点


php调用数据库

自己写的一个php的PDO的类,在调用的时候可以查询,插入的时候没有报错,但是插入没有成功,这是怎么回事。。。。。。。。。。
这个是调用的类

 config=$config;        $this->host=$this->config["host"];        $this->dbname=$this->config["dbname"];        $this->user=$this->config["user"];        $this->pwd=$this->config["pwd"];        $this->charset=$this->config["charset"];        //$this->open();    }    /*     * 打开数据库     */    public function open()    {        $this->conn=new PDO("mysql:host=".$this->host.";dbname=".$this->dbname,$this->user,$this->pwd);        $this->conn->query('set names '.$this->charset);    }    /*     * 增删改     */    public function execSql($sql)    {        $bool=$this->conn->exec($sql);        if($bool>0)        {            return "true";        }else        {            return false;        }    }    /*     * 查询一条数据    */    public function quer($sql,$mode=PDO::FETCH_ASSOC)    {        $result=$this->conn->query($sql);        $result->setFetchMode($mode);        $re=$result->fetch();        $result=null;        return $re;    }    /*     * 查询多条数据    */    public function querMore($sql,$mode=PDO::FETCH_ASSOC)    {        $result=$this->conn->query($sql);        $result->setFetchMode($mode);        $re=$result->fetchAll();        $result=null;        return $re;    }    /*查询指定表中有多少条记录*/    public function getTabRows($key,$tableName,$where)    {        $sql="select count(".$key.") as 'c' from ".$tableName." where ".$where."";        $result=$this->conn->query($sql);        $result->setFetchMode(PDO::FETCH_ASSOC);        $re=$result->fetch();        $result=null;        return intval($re['c']);    }    /*关闭数据库*/    public function closeConn()    {        $this->conn=null;    }}?>

这个是调用的方法

 open();$sql="INSERT INTO `test` (`name`, `nicheng`, `password`, `sex`, `icon`, `cardid`, `city`, `phone`, `qq`, `mail`, `liuyan`)      VALUES ('t', 't', 't', 't, 't', '1315', 'tttt', '598562', '79874564', 'tret', 'werterter')";echo $db->execSql($sql);

www.phpzy.comtrue/phpyy/1515.htmlTechArticle调用-自己写的一个php的PDO的类,有点问题,求大神指点 php调用数据库 自己写的一个php的PDO的类,在调用的时候可以查询,插入的时候没有报错,但是插入没有成功,这是怎么回事。。...

相关文章

相关频道:

PHP之友评论

今天推荐