$conditions[] = $this->getConnection()
->quoteInto('cat_index.category_id IN (?)', "{$filters[category_id]},{$Catids}");
用引号括住我的价值观。我想使用不带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);
}