In PHP5.1.6, how does one use real mysql preprocessing?

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.