ID: 36788
Updated by: [EMAIL PROTECTED]
Reported By: bubblenut at gmail dot com
-Status: Open
+Status: Feedback
Bug Type: PDO related
Operating System: Linux 2.6.12 (Kubuntu)
PHP Version: 5.1.2
New Comment:
It still doesn't work without execute() after prepare().
And after adding this execute() call, it works _just fine_.
Previous Comments:
------------------------------------------------------------------------
[2006-03-20 00:29:10] bubblenut at gmail dot com
OK, so change the fetches for fetchAlls an alter the expected and
actual results acordingly (yes I have tested with those methods). The
bug still stands. Prepared statements are not working for this install.
------------------------------------------------------------------------
[2006-03-19 22:47:39] [EMAIL PROTECTED]
This is what I get with your code (and this is expected):
-------------------
array(2) {
["id"]=>
string(1) "1"
[0]=>
string(1) "1"
}
Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[HY000]: General error: 2014 Cannot execute queries while
other unbuffered queries are active. Consider using
PDOStatement::fetchAll(). Alternatively, if your code is only ever
going to run against mysql, you may enable query buffering by setting
the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.' in /tmp/1.php:11
Stack trace:
#0 /tmp/1.php(11): PDO->prepare('SELECT id FROM ...')
#1 {main}
thrown in /tmp/1.php on line 11
-------------------
------------------------------------------------------------------------
[2006-03-19 16:00:20] bubblenut at gmail dot com
Description:
------------
It works fine on my Debian Sarge machine but on my Kubuntu laptop it
fails.
I have tried it with the follwing releases
PHP 5.1.0 CVS
PHP 5.1.1
PHP 5.1.2
PHP 5.1.2 CVS
Reproduce code:
---------------
<?php
//phpinfo();
$db = new PDO('mysql:host=localhost;dbname=test', 'root', '');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $db->prepare("SELECT id FROM recipe WHERE id=?");
$stmt->bindValue(1, 1);
$stmt->execute();
$res = $stmt->fetch();
var_dump($res);
$stmt = $db->prepare("SELECT id FROM recipe WHERE id=1");
$res = $stmt->fetch();
var_dump($res);
foreach($db->query("SELECT id FROM recipe WHERE id=1") as $res) {
var_dump($res);
}
Expected result:
----------------
array(2) {
["id"]=>
string(1) "1"
[0]=>
string(1) "1"
}
array(2) {
["id"]=>
string(1) "1"
[0]=>
string(1) "1"
}
array(2) {
["id"]=>
string(1) "1"
[0]=>
string(1) "1"
}
Actual result:
--------------
bool(false)
bool(false)
array(2) {
["id"]=>
string(1) "1"
[0]=>
string(1) "1"
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36788&edit=1