#34054 [Bgs->Opn]: pdo_mysql driver prepares all queries
| From: | jonathan+php at daikini dot com | Date: | Tue, 09 Aug 2005 18:12:17 +0000 |
| Subject: | #34054 [Bgs->Opn]: pdo_mysql driver prepares all queries | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-83254@lists.php.net to get a copy of this message | ||
ID: 34054
User updated by: jonathan+php at daikini dot com
Reported By: jonathan+php at daikini dot com
-Status: Bogus
+Status: Open
Bug Type: PDO related
Operating System: Mac OS X 10.4.2
PHP Version: 5.1.0b3
New Comment:
Forgot to reopen on my last comment
Previous Comments:
------------------------------------------------------------------------
[2005-08-09 19:52:04] jonathan+php at daikini dot com
PDO::exec() prepares and executes an SQL statement in a single
function call, returning the number of rows affected by the
statement.
I don't need to know the number of rows affected by the
statement. I need a PDOStatement object that I can call fetch
on.
------------------------------------------------------------------------
[2005-08-09 19:45:16] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Use exec() specifically designed for these cases.
------------------------------------------------------------------------
[2005-08-09 19:37:36] jonathan+php at daikini dot com
Description:
------------
Using MySQL 4.1.11
The pdo_mysql driver appears to attempt to prepare every query
that it processes. Unfortunately only certain query statement
types can be prepared in the current version of MySQL. See:
http://bugs.mysql.com/bug.php?id=6415
This is causing a failure in the example code posted.
Perhaps the pdo_mysql driver could look at the type of
statement it is processing and act accordingly and only
prepare statements that allow it or perhaps a new option or
method could be added so that it could be explicitly stated
that the query should not be prepared.
Reproduce code:
---------------
<?php
$db = new PDO("mysql:dbname=test;host=127.0.0.1", 'root', '');
$db->query('DROP TABLE IF EXISTS pdo_test');
$db->query('CREATE TABLE pdo_test (field1 int(11) default NULL, field2
varchar(20) default NULL)');
$query_that_should_not_fail = "SHOW CREATE TABLE pdo_test";
$result = $db->query($query_that_should_not_fail);
if (!$result) {
$errorInfo = $db->errorInfo();
print_r($errorInfo);
exit;
}
$row = $result->fetch(PDO_FETCH_ASSOC);
echo count($row);
?>
Expected result:
----------------
2
Actual result:
--------------
Array
(
[0] => HY000
[1] => 1295
[2] => This command is not supported in the prepared
statement protocol yet
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34054&edit=1