gpt4 book ai didi

Yii2 - 有事件记录的地方

转载 作者:行者123 更新时间:2023-12-03 23:13:55 25 4
gpt4 key购买 nike

是否可以使用事件记录创建 WHERE IN 条件?我正在查看文档,但找不到这个案例。我需要执行此查询并返回计数值。

这是我目前使用的方法:

public function static findProductsOnSale($ids)
{
return $this->find()->where(['product_id' => $ids])->count();
}

最佳答案

documentation about where()说:

['id' => [1, 2, 3], 'status' => 2] generates (id IN (1, 2, 3)) AND (status = 2)



所以你的方法应该是正确的。
如果你想使用 IN 那么你的代码应该是这样的:
public function static findProductsOnSale($ids)
{
return $this->find()->where(['in', 'product_id', $ids])->count();
}

关于Yii2 - 有事件记录的地方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31271499/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com