Mantis - Quercus
Viewing Issue Advanced Details
5388 minor always 03-06-13 05:00 03-06-13 05:36
konst  
 
normal  
new 4.0.36  
open  
none    
none  
0005388: PDOStatement.rowCount() doesn't meet DELETE, INSERT, or UPDATE statements specification
According to the specification of PDOStatement.rowCount() from http://php.net/manual/en/pdostatement.rowcount.php, [^]
it must return "the number of rows affected by the last DELETE, INSERT, or UPDATE statement".
"... SELECT statement, some databases may return the number of rows returned by that statement. However, this behaviour is not guaranteed"
However the current implementation of rowCount() was only returning the number of rows returned by SELECT statement.
By this commit the implementation has changed to return the number of rows affected by DELETE, INSERT, or UPDATE statements and also the number of rows returned by the SELECT statement

File: modules\quercus\src\com\caucho\quercus\lib\db\PDOStatement.java
Going to commit the fix to the following repository:
https://github.com/mdaniel/svn-caucho-com-resin [^]
or
https://github.com/konst-git/svn-caucho-com-resin [^]

Notes
(0006207)
konst   
03-06-13 05:07   
Example:

$sql = "UPDATE `character` SET `xp` = `xp` + 5 WHERE `xp` = 0 AND `character_id` = :id";

$st = PDO::prepare($sql);

$st->bindValue(':id', $id);
$st->execute();
$affectedRowsCount = $st->rowCount();

// Because of this issue, the $affectedRowsCount is always == 0
if ($affectedRowsCount == 0)
{
  echo "No characters found who need XP";
}

(0006208)
konst   
03-06-13 05:36   
Submitted a fix into file
File: modules\quercus\src\com\caucho\quercus\lib\db\PDOStatement.java
at repository:
https://github.com/konst-git/svn-caucho-com-resin [^]