YII2中使用with关联查询时,附带关联查询条件
前言:YII2中可以使用model中的relation关系进行表关联应用场景举例: 需要查找当前用户的信息,并关联查询(with)出该用户的发表过的文章,且文章的评论不为0的数据。<?php $user= user::find()->with([ 'articles' => function ($query){ $query->where('comment>0');
原创
2017-02-08 22:34:59 ·
15167 阅读 ·
0 评论