I am having the query like this
$criteria = new CDbCriteria(arr开发者_StackOverfloway(
'distinct' => true,
'select' => array('assets_id'),
'condition' => 'assets_id in (159)',
'with' => array('tbl_asset_mappings'=>array('select'=>array('catid')), 'tbl_assets_details'=>array('select'=>array('filetype','original_filename'))),
'together' => true
));
$result=TblAssets::model()->findAll($criteria);
But I am getting all the column values from firsttable only.I didnt get the column values from second tables.why?
My aim is getting assets_id from tblasset,tbl_asset_mappings.catid,tbl_assets_details.filetype,tbl_assets_details.original_filename
How can I achieve that.
You are querying for objects, so you will get the relations as child objects as relations like $post->author->name.
You need instead to do a join not a with. In this situation is more easier to write as Join raw-query.
Maybe would be more easier if you just write your own query rather than constructing throughout Yii
You can access related object like $model->relatedModel->attribute
.
Set a break point after model->findAll()
and look to $model->_related property
. You must have a collection of related models there.
精彩评论