Mam problem z pewnym zapytaniem. Istnieją dwie tabele: product i file. Jeden produkt ma przypisane kilka plików, w tabeli file kluczem obym jest product_id. W klasach modelu dziedziczącej po CActiveRecord dodalem takie metody:
Dla klasy product:
public function relations() { ); }
Dla klasy file:
public function relations() { // NOTE: you may need to adjust the relation name and the related // class name for the relations automatically generated below. ); }
Kontroler File zawiera metodę actionIndex:
public function actionIndex() { $this->pageTitle = Yii::app()->name.' - '.'Download'; 'criteria'=>array( 'condition'=>'product_id IS NOT NULL' ) )); 'dataProvider'=>$dataProvider, )); }
W jaki sposób w pliku widoku mogę odnieść się do danych z relacyjnej tabeli product? Plik widoku:
<?php $dataProvider->pagination->pageSize=100; 'dataProvider'=>$dataProvider, 'itemView'=>'_view', 'enablePagination'=>false, )); ?>