我的代码:$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的计数,但是当我跳过参数化并仅将变量本身添加到其位置时,我得到了准确的计数。这里发生了什么?
3 回答
慕少森
TA贡献2019条经验 获得超9个赞
我知道这个问题很老,但这对我有用:
$arrayOfValues = array(1,2,3,4,5);
$questionMarks = join(",", array_pad(array(), count($arrayOfValues), "?"));
$stmt = $dbh->prepare("update some_table set end_date = today where value_no in ($questionMarks)");
$stmt->execute($arrayOfValues);
添加回答
举报
0/150
提交
取消