Hi.
Say I have a model Cars, and a model Adverts which tells me on which newspaper I have published the advert for a car. A car can be on several Adverts at the same time. Say I want a list of Cars on the news, every car repeated for every (i know makes no sense but I need this way).
So the query would be something like this:
SELECT cars.* FROM cars JOIN adverts on cars.id = adverts.car where advert.date = A
This way I can obtain several times the same car, and this is what I need.
How do I translate this to Yii?
In Adverts I make a relation BELONGS_TO for car->cars.id
In Cars I make a relation HAS_MANY adverts.
my criteria is:
$cdb->with = array(
'rel_adverts'=>array(
// 'together'=>true,
'alias'=>"a",
'condition'=>'a.date = :A',
'params'=>array(':A'=>$mydate),
),
);
Cars::model()->findAll($cdb);
The problem is that I get every car only ONCE, even if it is published in several adverts!
How can I get "duplicate" Cars for every advert I have?
thanks