I have a model Images, and another model ImagePlans which tells me for every Station which images I should display. For every Station I have four available image slots, and of course the same Image can be displayed several times.
To find which images I should display on the given station I do something like this in the Station model:
$cdb = new CDbCriteria; $cdb->with = array( 'relation_to_plan'=>array( 'alias'=>"piani", 'condition'=>'piani.station = :hs', 'params'=>array(':hs'=>$this->id), ), ); $cdb->order = "piani.slot"; Images::model()->findAll($cdb);
So this should return ALL the images JOINED with the available slots.
In my case I have TWO different images, one on the first slot and the second on the remaining 3.
The executed query is correct, in fact if I run it in phpmyadmin it returns the correct result (4 rows), but the findAll just returns the TWO different models, while I need the second to be duplicated for two more times!
It’s like “group by” was selected, but the query doesn’t have this option!
How come? How can I return all my records?