Yii2的RESTful能否使用关联查询? [ 2.0 版本 ]
如题,Yii2的RESTful能否使用关联查询,我试了以下两种方式。但是都失败了(返回的json中没有category)。
$model = new Product();
$dataProvider = new ActiveDataProvider([
    'query' => $model->find()
        ->joinWith('category')
    	->where(['cid' => $cid]),
]);
return $dataProvider;
$products = Product::find()->joinWith('category')->where(['cid' => $cid])->all();
return $products;
共 4 个回答
- 
 - 
 - 
 - 
Mercy_stone 回答于 2016-06-03 16:48 举报DocumentRoot "D:\wamp\www\back-first\frontend\web" ServerName www.demo.com ServerAlias www.demo.com ErrorLog "logs/dummy-host.example.com-error.log" CustomLog "logs/dummy-host.example.com-access.log" common DocumentRoot "D:\wamp\www\back-first\backend\web" ServerName admin.demo.com ServerAlias admin.demo.com ErrorLog "logs/dummy-host2.example.com-error.log" CustomLog "logs/dummy-host2.example.com-access.log" common就是按照这个配置的httpd-vhosts.conf,从新安装一个新的advanced 再配置就能打开。但是从远程仓库pull下来的打不开
 
八宝粥 北京
            注册时间:2015-04-18
最后登录:2019-01-27
在线时长:26小时12分
    最后登录:2019-01-27
在线时长:26小时12分
- 粉丝30
 - 金钱4425
 - 威望20
 - 积分4885