What is the usage of PDO parameters (with length limitations, or bugs)?

Source: Internet
Author: User
Ask about the parameters of PDO (with length limit, or bug) usage:
Ask about the parameters of PDO (with length limit, or bug) usage:

There is the following PHP code:
$tids = ' 588316104237364, 573473840208171, 585814107854381 ';
$sql = ' SELECT trade_id,tid,trade_md5,receiver_md5,order_md5,status,llc_no,modified_time from Ep_trade WHERE the Tid in ('. $tids. ') and biz_id=? Limit 10000 ';
$param [0]=123;
$stmt->execute ($param);
Can execute correctly and return 3 rows of data

But in a different notation:
$sql = ' SELECT trade_id,tid,trade_md5,receiver_md5,order_md5,status,llc_no,modified_time from Ep_trade WHERE tid in (?) and biz_id=? Limit 10000 ';
To put the variable tid into the parameter:
$param [0]= $tids;
$param [1]=123;
$stmt->execute ($param);

Always return only the first row? Why is that?

Execution Environment: php5.1 CentOS 5.7, MySQL 5.1

Score a lot, pay a few $ also line, solve, thank you.

------Solution--------------------
It's not a PDO bug, it's PDO's rule.
There are several things to note about using PDO

1. Do not allow placeholders? Instead of a set of values, such as:

SELECT * FROM table where ID in (?);

Is the situation you encounter, when it is a set of values, only the first value is taken.

2. You cannot substitute placeholders for data table or column names, such as:

SELECT * FROM table order by?;


3. Do not allow placeholders to replace any other SQL syntax, such as:

Select Extract (? from Addtime) as DT from table;


------Solution--------------------
Positive Solution!
So Tid in (?)
Can write Find_in_set (tid,?)
  • 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.