note 99566 deleted from pdostatement.rowcount by danbrown
| From: | danbrown@php.net | Date: | Wed, 25 Aug 2010 03:04:45 +0000 |
| Subject: | note 99566 deleted from pdostatement.rowcount by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-172019@lists.php.net to get a copy of this message | ||
Note Submitter: josh dot ribakoff at gmail dot com
----
You are all wrong. Rowcount() behaves differently depending on the setting of
MYSQL_ATTR_USE_BUFFERED_QUERY
== Example to replicate ==
<?php
$config = array('dbname'=>'vaf', 'username'=>'root',
'password'=>'');
self::$dbAdapter = new Zend_Db_Adapter_Pdo_Mysql($config);
self::$dbAdapter->getConnection()
->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,false);
// can now replicate issue by calling rowCount() and observing 0 rows after a SELECT
?>
== Example to not-replicate ==
<?php
$config = array('dbname'=>'vaf', 'username'=>'root',
'password'=>'');
self::$dbAdapter = new Zend_Db_Adapter_Pdo_Mysql($config);
self::$dbAdapter->getConnection()
->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true);
// can not replicate issue, when you call rowCount() it will not return 0 and your clients will
think you're insane
?>
I actually wanted to go the other way around. All you guys are looking for hacks. I wanted to take
the time & understand the issue,
so I can replicate it in a unit test. The proper way to fix software is to write automated tests for
these kinds of things, you don't go
piling work around on top of work around. There's absolutely no need to wrap PDO, just learn to
use it right and test your software better.
Hope this is helpful to someone like myself