Test code: {code ...} when PHP5.1.6 is tested, Wireshark detects that the sent statement is: select * fromaccountwhereusername & #039; 23 & #039; limit & #039; 2 & #039; when PHP5.3 is tested, Wireshark detects that the sent statement is: select * fromaccou... test code:
setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $st = $pdo->prepare("select * from account where username =? limit ?,?"); $st->execute(array('buding',0,2)); $res = $st->fetchAll(); var_dump($res);?>
When PHP 5.1.6 is tested, Wireshark detects that the sent statement is:
Select * from account where username = '23' limit '2'
When testing in PHP 5.3, Wireshark detects that the sent statement is:
Select * from account where username =? Limit?
How can we use real mysql preprocessing in PHP 5.1.6? Is this a Bug, or is the method I use incorrect?
Reply content:
Test code:
setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $st = $pdo->prepare("select * from account where username =? limit ?,?"); $st->execute(array('buding',0,2)); $res = $st->fetchAll(); var_dump($res);?>
When PHP 5.1.6 is tested, Wireshark detects that the sent statement is:
Select * from account where username = '23' limit '2'
When testing in PHP 5.3, Wireshark detects that the sent statement is:
Select * from account where username =? Limit?
How can we use real mysql preprocessing in PHP 5.1.6? Is this a Bug, or is the method I use incorrect?
Before PHP5.3.6, parameter binding uses PHP preprocessing to escape parameters by default. If you use PDO, we recommend that you upgrade it to a version later than 5.3.6 and specify the encoding in DSN.