ID:               47655
 User updated by:  info at chromosoft dot be
 Reported By:      info at chromosoft dot be
 Status:           Bogus
 Bug Type:         PDO related
 Operating System: Ubuntu
 PHP Version:      5.2CVS-2009-03-14 (snap)
 New Comment:

Great, it works. But there is not much documentation on this option.
And I never thought that by default it is FALSE by default/


Thanks


Previous Comments:
------------------------------------------------------------------------

[2009-03-14 13:57:26] [email protected]

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.

------------------------------------------------------------------------

[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

Reply via email to