|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-03-14 13:57 UTC] scottmac@php.net
[2009-03-15 06:41 UTC] info at chromosoft dot be
[2009-03-15 08:13 UTC] info at chromosoft dot be
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 12:00:01 2025 UTC |
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 root@localhost on db 30 Query select * from tt where a = '1' 30 Quit Log with Mysqli 31 Connect root@localhost on db 31 Prepare [1] select * from tt where a = ? 31 Execute [1] select * from tt where a = 5 31 Quit