国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

LastInsertId() returns a problem. I tested it and found that when deleting and modifying, lastInsertId() returned "0", so use if(null!== $this->xxx->lastInsertId()){} to judge. Can't distinguish between insertion, deletion and addition? Is there still something wrong with my test code? Can someone who knows please answer it? Thank you) [Using singleton mode]
黃粱一夢夢黃梁
黃粱一夢夢黃梁 2019-07-23 22:07:47
0
1
1282

class MyDb{

..........

public function test($sql)
{
$this->affect_nums = $this-> ;pdo->exec($sql);//Number of rows affected
if ($this->affect_nums>0) {
$this->insertId = $this->pdo-> lastInsertId();//Last insert id
if(null !== $this->insertId){
? ? ? ? ? echo "Insert successfully.";
? ? } else {
? ? ? ? ? ? ? ? ? ? echo "Modify/Delete Success.";
}
} else {
? ? ? $error = $this->pdo->errorInfo();
? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? } else {
? ? ? ? ? ?}

}

$MyDb = MyDb::getInstance();
//Table structure test2((auto_increment,primary key),name,password);
$MyDb ->test("INSERT INTO test2(name,password) values('Xiaohua','123')");
echo $MyDb->affect_nums.",".$MyDb->insertId;
echo "<br>";
$MyDb->test("UPDATE test2 SET name='Zeng Hua' WHERE name='Xiaohua'");
echo $MyDb-> affect_nums.",".$MyDb->insertId;
echo "<br>";
$MyDb->test("DELETE FROM test2 WHERE name='Zeng Hua'");
echo $MyDb->affect_nums.",".$MyDb->insertId;

黃粱一夢夢黃梁
黃粱一夢夢黃梁

reply all(1)
黃粱一夢夢黃梁

Sorry, lastInsertid() in the code is missing two brackets. I don’t know why it was missing when I copied it. The problem is not this...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template