我使用以下 sql 来获取我的表的特定行的字段的值que_id
,它工作正常。请注意 que_id(auto-incremented) 和行号是不一样的。
$qry_que_getid = $connexion->query('SELECT somefield FROM table ORDER BY somefield ASC LIMIT '.$lineNumberSeeked.', 1');
$row = $qry_que_getid->fetch(PDO::FETCH_ASSOC);
echo $row['que_id'];
当我尝试按如下方式将该查询转换为准备好的查询时,出现错误并且我没有得到它:
$qry_que_getid = $connexion->prepare('SELECT somefield FROM table ORDER BY somefield ASC LIMIT ?, 1');
$qry_que_getid->execute(array(4));
$row = $qry_que_getid->fetch(PDO::FETCH_ASSOC);
echo $row['que_id'];
我收到以下错误SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''3', 1' at line 1
希望有人能帮助我理解。先感谢您。干杯。马克。