ID: 47655
Updated by: [email protected]
Reported By: info at chromosoft dot be
-Status: Open
+Status: Bogus
Bug Type: PDO related
Operating System: Ubuntu
PHP Version: 5.2CVS-2009-03-14 (snap)
New Comment:
This was intended due to the mysql api not being quite ready when PDO
was written. I believe you can use
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
But there might be bugs with this.
Previous Comments:
------------------------------------------------------------------------
[2009-03-14 07:46:43] info at chromosoft dot be
Description:
------------
Hi,
The prepare is allways emulated on the mysql DB.
But if you use mysqli the prepare work correctly.
MySQL : 5.0.51a
PHP : 5.2.4-2ubuntu5.5
Reproduce code:
---------------
Code with PDO :
$dbh = new PDO('mysql:host=localhost;dbname=db', 'root' , '');
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sth = $dbh->prepare('select * from tt where a = ?');
$sth->execute(array(1));
$sth->fetch();
unset($sth);
Code with Mysqli :
$mysqli = new mysqli("localhost", "root", "", "db");
$a = 5;
if ($stmt = $mysqli->prepare("select * from tt where a = ?"))
{
$stmt->bind_param("i", $a);
$stmt->execute();
}
$mysqli->close();
Actual result:
--------------
Log with PDO
30 Connect r...@localhost on db
30 Query select * from tt where a = '1'
30 Quit
Log with Mysqli
31 Connect r...@localhost on db
31 Prepare [1] select * from tt where a = ?
31 Execute [1] select * from tt where a = 5
31 Quit
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47655&edit=1