note 99566 added to pdostatement.rowcount
| From: | josh dot ribakoff at gmail dot com | Date: | Wed, 25 Aug 2010 02:47:10 +0000 |
| Subject: | note 99566 added to pdostatement.rowcount | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172018@lists.php.net to get a copy of this message | ||
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
----
Server IP: 64.71.164.2
Probable Submitter: 98.77.57.170
----
Manual Page -- http://www.php.net/manual/en/pdostatement.rowcount.php
Edit -- https://master.php.net/note/edit/99566
Del: integrated -- https://master.php.net/note/delete/99566/integrated
Del: useless -- https://master.php.net/note/delete/99566/useless
Del: bad code -- https://master.php.net/note/delete/99566/bad+code
Del: spam -- https://master.php.net/note/delete/99566/spam
Del: non-english -- https://master.php.net/note/delete/99566/non-english
Del: in docs -- https://master.php.net/note/delete/99566/in+docs
Del: other reasons-- https://master.php.net/note/delete/99566
Reject -- https://master.php.net/note/reject/99566
Search -- https://master.php.net/manage/user-notes.php