将 WHERE IN 子句与 PDO 绑定参数
我的代码:
$myArray = implode($myArray, ',');
$sth = $dbh->prepare('SELECT foo FROM bar WHERE ids IN (:ids)');
$sth->bindParam(':ids', $myArray);
$sth->execute();
$result = $sth->fetch();
echo $sth->rowCount();
始终显示计数 1,但是当我跳过参数化,只需将变量本身添加到其位置时,我就会得到准确的计数。这是怎么回事?