$conditions[] = $this->getConnection()
->quoteInto('cat_index.category_id IN (?)', "{$filters[category_id]},{$Catids}");
quote into 将我的值括在引号中。我想使用相同的方法而不使用 quoteInto 方法。所以基本上,我想知道什么方法可以在不添加引号的情况下执行相同的操作
最佳答案
为了使用 in
的参数化查询,即使使用 in
,您也必须使用 ?
(或某个值)指定参数数量>.
cat_index.category_id IN (?,?)
您可以使用参数数组来完成此操作。
// array_merge Catids instead? is it an array?
$args = array($filters["category_id"], $Catids);
$query = "cat_index.category_id IN (" .
implode(',', array_fill(0, count($args), '?'))
. ")";
foreach ($args as $arg) {
$connection->quoteInto($query, $arg);
}
关于mysql - 替代 Pdo 查询的 quoteInto 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18614295/