1
我想在findFirst
中使用IN
子句,但它似乎不起作用?是否可以在Phalcon中使用IN子句運行findFirst()?
預計代碼,或類似的東西:
$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();
哇!文檔中的語法在哪裏? – igorsantos07
檢查我的鏈接。它在我上面給出的鏈接的第三個代碼塊中。 –
我敢打賭,它一定是新東西。去年我一直在尋找這樣的解決方案兩次,之前沒有看到過。它看起來也適用於字符串! – Luke