mySQL and PDOStatement::rowCount()

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
EdTheHead
Forum Newbie
Posts: 1
Joined: Thu Dec 03, 2009 3:47 am

mySQL and PDOStatement::rowCount()

Post by EdTheHead »

Hi,

According to the php documentation for PDOStatement::rowCount() http://www.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 I do not understand from this is
behaviour is not guaranteed for all databases
. These databases they refer to, is this mySQL, MSSQL, Oracle, etc or is it the database engine (ie InnoDB) or the database version (mySQL 4, 5.0, 5.1)?

All the testing I have done so far resulted in the correct results returned by the rowCount() function - all the testing was done with a php version greater than 5.2.8 and the databases were all mySQL (either 4, 5.0 or 5.1). I am wondering now in this testing context, does the rowCount() function for php versions greater than 5.2.8 work on all mySQL database versions or according to the php documentation that it might not be working on some mySQL versions?

On one server we are running Debian with php 5.2.0-8+etch15 (Stable release for Debian etch) but the rowCount() function is not returning the correct results for this php version (does not matter what mySQL database version is used). The hosting company keeps referring back to the php documentation and quoting that the rowCount() function will not work.

What I want to know is this inconsistent results rather related to the php version than to the mysql database?

This probably a question a should pose to the php developers: for mySQL, what versions of php will the PDOStatement::rowCount() return the correct results?

Regards
Post Reply