yii2.0 with 筛选问题

具体模仿瞎 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]);   
 }}

猜你喜欢

转载自blog.csdn.net/yuxuemu/article/details/78327683
今日推荐