[solved] PDO affected rows question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

[solved] PDO affected rows question

Post by josh »

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 ==

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);
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 ;-)
Post Reply