class MyDb{
....
public function test($sql)
{
$this->affect_nums = $this->pdo->exec($sql);//Affect Anzahl der Zeilen
if ($this->affect_nums>0) {
$this->insertId = $this->pdo->lastInsertId();//Letzte Einfügungs-ID
if(null !== $this -& gt; insertid) {
echo „erfolgreich eingefügt.“;
mit using using out out out off through out ‐ ; ->test("INSERT INTO test2(Name,Passwort) Werte('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;
抱歉,代码中的lastInsertid()少了两个括号,复制的时候不知道为什么少了,问题不是这个...