Saturday, June 11, 2011

Yii - Right join

I wanted to learn something new so I decided to create a website using the framework Yii (more info). It's written in PHP and I think it's pretty cool.

Yii comes with rich features: MVC, DAO/ActiveRecord, I18N/L10N, caching, authentication and role-based access control, scaffolding, testing, etc. It can reduce your development time significantly.

But I'm having a problem that I can't solve right now.


I have 2 tables :
- tbl_prono (id, game_id, ...) : there are 2 rows of data
- tbl_game (id, date, team_id,...) : there are 3 rows of data

In my model Prono I did the following relation:
return array(
'game'=>array(self::BELONGS_TO, 'Game', 'game_id'),

I created the following dataprovider in an action (PronoController):

$dataProvider=new CActiveDataProvider('Prono', array(
'with'=>array('game'=>array('joinType'=>'RIGHT JOIN')),
// please note the RIGHT JOIN


It generates a correct sql querry. But it returns 2 rows instead of 3 !
It should return 3 rows because I'm doing a "right join" and tbl_game has 3 rows.

So, in my CgridView, I can see only 2 rows...

I couldn't find a solution to display 3 rows....

1 comment:

Dibya Prabo S said...

Any solution for this problem??
help me bos..