Reputation: 81
I'm having trouble with queryes on Yii 1.1 .
$sql = 'select a.name, b.name, c.name from ';
$sql .= $tab1.' AS a ';
$sql .= 'RIGHT JOIN '.$tab2.' AS b ON b.id = a.f_id';
$sql .= 'RIGHT JOIN '.$tab3.' AS c ON c.id = b.f_id';
$result = Yii::app()->db->createCommand($sql)->queryAll();
The returned array will have only one value tagged as name instead of three.
What am I doing wrong? thank you.
PS: I'm absolutely sure that each model and table is correct, I'm trying to implement an upgrade on a long-existing system.
Upvotes: 0
Views: 61
Reputation: 222582
The three columns in the resultset have the same name. This is ambiguous, and confuses your client. Use column aliases to remove the ambiguity:
$sql = 'select a.name a_name, b.name b_name, c.name c_name from ';
Upvotes: 3