yii2.0 with 筛选问题

来源:互联网 发布:mac照片文件夹在哪 编辑:程序博客网 时间:2024/05/16 14:39
具体模仿瞎 main的就行了
$list = $data->asArray()    ->with([ 'wxpayrecord' => function($query) use($type){        $query->andWhere(['=','pay_type',$type])->andWhere('status=1')->orderBy('created DESC');    },])    ->offset($pages->offset)->limit($pages->limit)->all();
还可以使用:
class User extends ActiveRecord{  
  public function getBooks()   
 {        
return $this->hasMany(Item::className(), ['owner_id' => 'id'])->onCondition(['category_id' => 1]);   
 }}
原创粉丝点击