|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-02-23 17:29 UTC] lists at cyberlot dot net
Description:
------------
Compiled from latest cvs I can't seem to do more then one query before pdo_mysql just dies. This is on a per object basis not on a overall basis as I can create a new object and perform another query
This seems to be limited to the use of the query function.. A single use of the query function seems to somehow taint the whole object preventing any further querys from happening.
Note the below function IF you move the query based statement from the last item to the first item the query will work but now the excute statements fail.
It doesn't matter what order I try soon as I run a $db1->query the object is useless for any futher querys.
Reproduce code:
---------------
$dsn = 'mysql:dbname=mysql;host=localhost';
$db1 = new PDO($dsn, 'root', '');
$stm = $db1->prepare('SELECT * FROM help_category LIMIT 1');
$stm->execute();
print_r($stm->fetch(PDO_FETCH_ASSOC));
$stm = $db1->prepare('SELECT * FROM help_category LIMIT 1');
$stm->execute();
print_r($stm->fetch(PDO_FETCH_ASSOC));
$result = $db1->query('SELECT * FROM help_category LIMIT 1');
print_r($result->fetch(PDO_FETCH_ASSOC));
Expected result:
----------------
Array
(
[help_category_id] => 0
[name] => Point properties
[parent_category_id] => 24
[url] =>
)
Array
(
[help_category_id] => 0
[name] => Point properties
[parent_category_id] => 24
[url] =>
)
Array
(
[help_category_id] => 0
[name] => Point properties
[parent_category_id] => 24
[url] =>
)
Actual result:
--------------
Array
(
[help_category_id] => 0
[name] => Point properties
[parent_category_id] => 24
[url] =>
)
Array
(
[help_category_id] => 0
[name] => Point properties
[parent_category_id] => 24
[url] =>
)
Fatal error: Call to a member function fetch() on a non-object in /root/test.php on line 15
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 15:00:01 2025 UTC |
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2014 Commands out of sync; You can't run this command now' in /root/test.php:18 Stack trace: #0 /root/test.php(18): PDO->query('SELECT * FROM h...') #1 {main} thrown in /root/test.php on line 18 [root@fs root]#