Yii2-活动记录的位置
是否有可能在有活动记录的情况下确定位置?我正在查阅文件,但找不到这个案子。我需要执行此查询并返回计数值 这是我目前使用的方法:Yii2-活动记录的位置,yii2,Yii2,是否有可能在有活动记录的情况下确定位置?我正在查阅文件,但找不到这个案子。我需要执行此查询并返回计数值 这是我目前使用的方法: public function static findProductsOnSale($ids) { return $this->find()->where(['product_id' => $ids])->count(); } 正如上面所说: ['id'=>[1,2,3],'status'=>2]生成(在(1,2
public function static findProductsOnSale($ids)
{
return $this->find()->where(['product_id' => $ids])->count();
}
正如上面所说:
['id'=>[1,2,3],'status'=>2]生成(在(1,2,3)中的id)和(status=2)
所以你的方法应该是正确的。
如果要在中使用,则代码应如下所示:
public function static findProductsOnSale($ids)
{
return $this->find()->where(['in', 'product_id', $ids])->count();
}