binkabir
(Binkabir)
1
Hello,
i have 2 AR classes e.g Cars and CarsCondition
my relations function in the cars AR class
is
public function relations
return array(
'carCondition'=>array(self::HAS_MANY, 'CarsCondition', 'car_id')
);
the carsCondition db table looks like this
id,car_id , condition
now i wish to find the condition in a car inside my Cars AR class,
really dont have ideas on how to do that
have tried this but didn’t work
$status = $this->carCondition->condtion
any help?
Gasim
(G Gasimzada)
2
if I am not mistaken,
since carCondition relation is HAS_MANY it is an array. Just try this:
foreach($this->carCondition as $condition) {
echo $condition;
}
Gasim
(G Gasimzada)
4
Oops. My fault.
its $condition->condition (since there is a condition variable inside carCondition).
If that doesn’t work, how do you get data for the AR. Are you using:
$models = Car::model()->with(‘carCondition’)->findAll(); //or something similar
?