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,?)