【发布时间】:2016-07-20 19:04:14
【问题描述】:
我想在findFirst 中使用IN 子句,但它似乎不起作用?
预期的代码,或类似的东西:
$item = Item::findFirst([
'conditions' => 'categories IN :cats: AND released < :now:',
'order' => 'id ASC',
'bind' => [
'cats' => $this->categories,
'released' => time()
],
]);
我尝试使用 bindTypes,但没有这样的“列表”或“数组”类型(而且,这会比预期的更冗长)...
我知道我可以通过查询生成器做到这一点,但我希望让它更惯用:
$item = Item::query()
->inWhere('categories', $this->categories)
->andWhere('released < :now:', ['now' => time()])
->orderBy('id ASC')
->limit(1)
->execute()
->getFirst();
【问题讨论】:
标签: phalcon phalcon-orm