PDO limit bug

Source: Internet
Author: User

PDO has a limit bug (MySQL)

The data type needs to be specified, and the two parameters following limit must be numerical. Otherwise, no data can be obtained.

Example 1:

$ DSN = "MYSQL: host = 127.0.0.1; Port = 3306; dbname = dab"; $ DBH = new PDO ($ DSN, 'root ',''); $ SQL = "select * From dab_ntos_admin limit ?,? "; $…… = $ DBH-> prepare ($ SQL); $……> bindvalue (1, + '0', PDO: param_int ); // The third parameter specifies the parameter type, and the second parameter converts the type (converted to the numerical type) with the plus sign $ something-> bindvalue (2, + '1', PDO:: param_int); // The third parameter specifies the parameter type, and the second parameter converts the type (converted to a value type) with the plus sign (+) $ something-> execute (); foreach ($ something as $ row) {echo var_dump ($ row );}

Example 2:

$ DSN = "MYSQL: host = 127.0.0.1; Port = 3306; dbname = dab"; $ DBH = new PDO ($ DSN, 'root ',''); $ SQL = "select * From dab_ntos_admin limit: Start,: Limit"; $…… = $ DBH-> prepare ($ SQL); $ ...... bindvalue (': start ', + '0', PDO: param_int); // The third parameter specifies the parameter type, and the second parameter is converted to the value type with the + sign) $ something-> bindvalue (': Limit', + '1', PDO: param_int); // The third parameter specifies the parameter type, the second parameter is converted to a numeric value using the plus sign (+) $ something-> execute (); foreach ($ something as $ row) {echo var_dump ($ row );}

 

PDO limit bug

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.