Write Yourself a PHP PDO class, when the call can query, insert the time without error, but the insertion did not succeed, this is how the matter ....
This is the calling class.
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 (); }/* Open database */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); }/* * additions/deletions/Public function Execsql ($sql) {$bool = $this->conn->exec ($sql); if ($bool >0) {return "true"; }else {return false; }/* * Query a data */Public Function Quer ($sql, $mode =pdo::fetch_assoc) {$result = $this->CONN-&G T;query ($sql); $result->setfetchmode ($mode); $re = $result->fetch (); $result =null; Return$re; }/* * Query multiple Data */Public function Quermore ($sql, $mode =pdo::fetch_assoc) {$result = $this->conn-> ; query ($sql); $result->setfetchmode ($mode); $re = $result->fetchall (); $result =null; return $re; }/* Query Specifies how many records are in the table */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 ']); }/* Close database */Public Function Closeconn () {$this->conn=null; }}?>
This is the method of invocation
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);