[solved] PDO affected rows question
Posted: Tue Aug 24, 2010 8:47 pm
http://us3.php.net/manual/en/pdostatement.rowcount.php
If the last SQL statement executed by the associated PDOStatement was a SELECT statement, some databases may return the number of rows returned by that statement. However, this behaviour is not guaranteed for all databases and should not be relied on for portable applications.
What is "some databases"? My client is running php 5.2.11 and mysql 5.0.81 - I tried to match this as closely as possible and couldn't replicate the bug on my machine. Under what conditions would PDO return the rows for a select statement VS not?
== solved ==
Depending on if the buffered query setting is true or false, pdo's rowCount() method behaves differently. Apparently that setting likes to not take affect during a debugging session too 
If the last SQL statement executed by the associated PDOStatement was a SELECT statement, some databases may return the number of rows returned by that statement. However, this behaviour is not guaranteed for all databases and should not be relied on for portable applications.
What is "some databases"? My client is running php 5.2.11 and mysql 5.0.81 - I tried to match this as closely as possible and couldn't replicate the bug on my machine. Under what conditions would PDO return the rows for a select statement VS not?
== solved ==
Code: Select all
self::$dbAdapter = new Zend_Db_Adapter_Pdo_Mysql( array('dbname'=>'vaf', 'username'=>'root', 'password'=>'') );
self::$dbAdapter->getConnection()->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,false);