可能重复:
PHP PDO - Num Rows
我无法在PHP和MySQL中返回受影响的行数:
$sql = "SELECT `id` FROM `bookmark` WHERE `userid` = :userid AND `hash` = :hash";
$sql_do = $db->prepare($sql);
$sql_do->bindParam(':userid', $userid, PDO::PARAM_INT);
$sql_do->bindParam(':hash', $hash, PDO::PARAM_STR);
$sql_do->execute();
$number = $db->query("SELECT FOUND_ROWS()")->fetchColumn();
返回0.
答案 0 :(得分:0)
您可以在删除或更新时使用它
echo 'I have deleted ' . $db->affectedRows() . ' users';
或
echo mysql_affected_rows();