@wqzjd #4楼 既然你拿不出来具体的例子,我给你举个栗子把,
我如果按照条件批量查询所有的customer
https://github.com/fecshop/yii2_fecshop/blob/master/services/Customer.php
/**
* @property $filter|array
* get collection by $filter
* example filter:
* [
* 'numPerPage' => 20,
* 'pageNum' => 1,
* 'orderBy' => ['_id' => SORT_DESC, 'sku' => SORT_ASC ],
* 'where' => [
* ['>','price','1'],
* ['<','price','10'],
* ['sku' => 'uk10001'],
* ],
* 'asArray' => true,
* ]
* 通过上面的filter数组,得到过滤后的用户数据列表集合。
*/
protected function actionColl($filter = '')
{
$query = $this->_customerModel->find();
$query = Yii::$service->helper->ar->getCollByFilter($query, $filter);
//var_dump($query->all());exit;
return [
'coll' => $query->all(),
'count'=> $query->limit(null)->offset(null)->count(),
];
}
如果 $filter
参数的example data 你看不懂,那就只有学习Yii2了