我是 PDO 的新手,并且是准备好的陈述。为什么会这样:
$sth = $dbh->prepare("SELECT *
FROM skyrim_ingredients
WHERE ing_name
IN ('blue butterfly wing', 'blue dartwing', 'blue mountain flower');");
while($row = $sth->fetch()) {
echo $row['ing_id'];
}
...但这不是:
$ing_string = 'blue butterfly wing', 'blue dartwing', 'blue mountain flower';
$sth = $dbh->prepare("SELECT *
FROM skyrim_ingredients
WHERE ing_name
IN (?);");
$sth->bindParam(1, $ing_string);
$sth->execute();
while($row = $sth->fetch()) {
echo $row['ing_id'];
}
我读到您不能对表或列使用参数,IN 子句也是这种情况吗?