Reputation: 75
I am using yii and CDbCriteria to fetch results from 3 tables using join. Here is what i have done till now:
$criteria->select = 't.product_id, t.title, t1.title, t2.filename,';
$criteria->join = 'INNER JOIN shop_category as t1 ON t1.category_id = t.category_id';
$criteria->join .= ' INNER JOIN shop_image as t2 ON t2.product_id = t.product_id';
but it is only giving me t.product_id and t.title and not other two. When i ran this query on phpMyAdmin it gave all results perfectly! What am i doing wrong?
Upvotes: 1
Views: 437
Reputation: 7265
if you use criteria with active record, the data populated is in bounds of models properties and attributes,
but you can have other columns as properties of the model,
lest suppose you have productTitle and productFilename in your model:
$criteria->select = 't.product_id, t.title, t1.title as productTitle, t2.filename as productFilename';
Upvotes: 1