如何在此显示受影响的行数:
$sql = $conn->prepare ("UPDATE countries SET country=:country");
$sql->bindValue(":country", "blablaa");
$sql->execute();
如何用这个显示最后插入的ID:
$sql = $conn->prepare ("INSERT INTO countries (country) VALUES (:country)");
$sql->bindValue(":country", "test");
$sql->execute();
echo $sql->lastInsertId(); // id of last inserted
我试过了,但是收到了对未定义方法PDO::lastInsertId()
答案 0 :(得分:12)
我认为这可以帮到你:
PDOStatement对象:: rowCount时()
返回由相应PDOStatement对象执行的最后一个DELETE,INSERT或UPDATE语句影响的行数。 http://php.net/manual/en/pdostatement.rowcount.php
答案 1 :(得分:7)