#35391 [NEW]: PDO::exec does not return number of affected rows

From: Date: Fri, 25 Nov 2005 12:40:15 +0000
Subject: #35391 [NEW]: PDO::exec does not return number of affected rows
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-88951@lists.php.net to get a copy of this message
From: chris at x98 dot org Operating system: Windows XP SP 2 PHP version: 5.1.0 PHP Bug Type: MySQL related Bug description: PDO::exec does not return number of affected rows Description: ------------ According to the docs, PDO::exec should return the number of rows affected by the INSERT/DELETE/... statement. In my setup (WinXPSP2/Apache 2.0.55/PHP 5.1.0/mysql 4.1.15-nt), int(0) is returned instead always. Reproduce code: --------------- // table test has two columns (id and value) $db = new PDO('mysql:host=localhost;dbname=test', 'xxxxx', 'xxxxx'); for ($i=1;$i<5;$i++) { $count = $db->exec("INSERT INTO TEST (id, value) VALUES ($i, 1)"); var_dump($count); } $count = $db->exec("DELETE FROM test WHERE id>0"); var_dump($count); Expected result: ---------------- int(1) int(1) int(1) int(1) int(4) (assuming table test was empty before) Actual result: -------------- int(0) int(0) int(0) int(0) int(0) -- Edit bug report at http://bugs.php.net/?id=35391&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=35391&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=35391&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=35391&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=35391&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=35391&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=35391&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=35391&r=needscript Try newer version: http://bugs.php.net/fix.php?id=35391&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=35391&r=support Expected behavior: http://bugs.php.net/fix.php?id=35391&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=35391&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=35391&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=35391&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35391&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=35391&r=dst IIS Stability: http://bugs.php.net/fix.php?id=35391&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=35391&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=35391&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=35391&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=35391&r=mysqlcfg

« previous php.bugs (#88951) next »