Hi!
I am newbie and i have some problem with useing dataprovider. I have 2 tables in mysql database. The connection work. championship (table) has 2 column : id and name. The match (table) has 4 column : id, name1, name2, championshipId (FK: championshipId).
My gridList.php (view), with 2 param: dataprovider and labels.
<?php
$this->widget(‘zii.widgets.grid.CGridView’, array(
'id'=>'match-grid',
'dataProvider'=>$dataProvider,
'enablePagination'=>false,
'columns'=>$labels,
)
);
2 models exist with connection (Championship, Match)
MATCH
public function relations()
{
return array(
'championship'=>array(self::BELONGS_TO, 'Championship', 'championshipId'),
);
}
CHAMPIONSHIP
public function relations()
{
return array(
'matches'=>array(self::HAS_MANY, 'Match', 'championshipId'),
);
}
if (isset($_POST[‘Championship’])) {
$model->attributes = $_POST['Championship'];
$championship = Championship::getChampionshipByName($model->name);
$dataProvider = new CActiveDataProvider('Match',
array(
'criteria' => array(
'with' => array(
'championship'=>array('joinType'=>'RIGHT JOIN'),
),
//'condition1'=>'championship.id'
'together'=>true,
'order' => 'date',
),
'pagination' => array(
'pageSize' => 500,
),
)
);
$labels= array_flip(Match::attributeLabels());
$this->renderPartial('watcher/gridList', array('labels' => $labels, 'dataProvider' => $dataProvider));
}
If post coming with "Championship" it contains just the name of the Championship. and after that i try select all match for a championship.
If somebody could help me that wpuld be great.
Ui.: sorry for my english.