Код: Выделить всё
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'orders'=>array(self::HAS_MANY, 'Order', 'user_id'),
//'PrOr'=>array(self::BELONGS_TO, 'OrderProduct', 'order_id'),
);
}
Код: Выделить всё
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'PrOr'=>array(self::HAS_MANY, 'OrderProduct', 'order_id'),
);
}
Код: Выделить всё
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'product'=>array(self::BELONGS_TO, 'Product', 'product_id'),
//'PrOr'=>array(self::BELONGS_TO, 'Order', 'order_id'),
);
}
В итоге мне нужно сделать двойной цикл для вывода всех связей
Код: Выделить всё
foreach($model->orders as $key=>$order) {
//// .... вывод номера заказа
foreach($order->PrOr as $PrOr){
///// ..... продукты заказа (получаем через связь 'product'=>array(self::BELONGS_TO, 'Product', 'product_id'), )
echo $PrOr->product->name;
}
}