Database problem

Hi, i am new using the yii framework. I have 3 DB tables: Games, BetGames, BetStatus.

I want to get all the games in my Game table no matter if you have make a Bet in that game.

I think it is a problem with the relations but i dont know how to sole. Please send me a link or and app where i can see how can i modify the relations in order to make it (Right Outer). If you think that it could be something different plesase tell me.

‘join’=>‘RIGHT OUTER JOIN juego ON apuestaquiniela.juego_id=juego.id LEFT OUTER JOIN quiniela ON apuestaquiniela.quiniela_id=quiniela.id’,

That is the join that i am using…

I got the following error:

Base table or view not found: 1146 Table ‘quiniela.juego’ doesn’t exist. The SQL statement executed was: SELECT COUNT(*) FROM tbl_apuestaquiniela t RIGHT OUTER JOIN juego ON apuestaquiniela.juego_id=juego.id LEFT OUTER JOIN quiniela ON apuestaquiniela.quiniela_id=quiniela.id WHERE quiniela.id_usuario=:uid AND quiniela.numero=:qid

Seems you call it ‘tbl_apuestaquiniela’ with alias ‘t’ and then you perform joins with ‘apuestaquiniela’… wrong alias?

cbi

The SQL statement that works is:

SELECT *FROM tbl_juego J LEFT JOIN (tbl_apuestaquiniela INNER JOIN tbl_quiniela ON tbl_quiniela. Id= tbl_apuestaquiniela.quiniela_id) ON J.id = tbl_apuestaquiniela.juego_id AND tbl_quiniela.id_usuario=100000599361420 AND tbl_quiniela.numero=2

How can i put that into a CActiveDataProvider?

CActiveDataProvider implements a data provider based on CActiveRecord. So, in order to work flawless you should create an CActiveRecord class with the structure of the SQL result.

See http://www.yiiframework.com/doc/api/1.1/CActiveDataProvider and http://www.yiiframework.com/doc/api/1.1/CActiveRecord for more details.

Other solution could be creating three CActiveRecord classes, one per table and then working with relations (so, deprecating that SQL join statement). See relations section at CActiveRecord documentation.

cbi