Wednesday 15 July 2015

php - yii mutliple joins not showing all columns -



php - yii mutliple joins not showing all columns -

i have next createcommand:

$query = yii::app()->db->createcommand() ->select('q.*, qcia.value, qcim.value') ->from('quotas q') ->leftjoin('quota_company_item_activations qcia', 'qcia.quota_id = q.id') ->leftjoin('quota_company_item_mrcs qcim', 'qcim.quota_id = q.id') ->where('q.id=:id', array(':id' => $quota_id)) ->queryrow();

in result array should have twice value field, array looks that:

[id] => 3 [name] => september sales quotas [company_id] => 1 [user_id] => 22 [datestart] => 2014-09-01 [dateend] => 2014-09-30 [created] => 2014-09-30 21:12:44 [modified] => 0000-00-00 00:00:00 [value] => 60.00

why retrieves 1 value (from lastly leftjoin) ?

you need utilize alias 1 of values.. php arrays indexed keys.. first value overwritten sec value this

$query = yii::app()->db->createcommand() ->select('q.*, qcia.value avalue, qcim.value mvalue') ->from('quotas q') ->leftjoin('quota_company_item_activations qcia', 'qcia.quota_id = q.id') ->leftjoin('quota_company_item_mrcs qcim', 'qcim.quota_id = q.id') ->where('q.id=:id', array(':id' => $quota_id)) ->queryrow();

php activerecord yii

No comments:

Post a Comment