0

Possible Duplicate:
PHP PDO - Num Rows

I can't return the number of affected rows in PHP and 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();

returns 0.

Community
  • 1
  • 1
  • Maybe http://stackoverflow.com/questions/2700621/php-pdo-num-rows or http://stackoverflow.com/questions/460010/work-around-for-php5s-pdo-rowcount-mysql-issue will help you? – Kyle Dec 06 '12 at 17:21
  • 1
    `FOUND_ROWS()` Description: For a SELECT with a LIMIT clause, the number of rows that would be returned were there no LIMIT clause – RTB Dec 06 '12 at 17:22
  • `FOUND_ROWS` is used when a query is ran with `SQL_CALC_FOUND_ROWS`. – gen_Eric Dec 06 '12 at 17:23
  • You seem not to have done any research at all. PHP.net and GOOGLE are you best friends. Only after that ask your questions here :) GL with the above hints... – Djumaka Dec 06 '12 at 21:46

1 Answers1

0

You can use it on delete or on update

echo 'I have deleted ' . $db->affectedRows() . ' users';

or

echo mysql_affected_rows();
Kld
  • 6,970
  • 3
  • 37
  • 50