Yii Framework Forum: Show Mysql Data With Dataprovider - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Show Mysql Data With Dataprovider Rate Topic: -----

#1 User is offline   pocok 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 27-February 14

Posted 07 March 2014 - 10:10 AM

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.
0

#2 User is offline   pocok 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 27-February 14

Posted 07 March 2014 - 10:11 AM

Sorry my bad copy/paste
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users