Render A Mysql View (Select...)


I have in my Yii connected MySql database a view based on a select statement with sum and group by actions.

This gives a score overview, something like:

Team: Points:

one 30

two 60

How should I proceed to render this MySql-view in my application? Can a Gii generator be usefull? (Model works but Controller, not since no Primary Key, and don’t need CRUD).

Or should I just reproduce the sql-select in a function of the Model?

And last but not least, anyone an idea how to refresh the score-page automatically after x seconds?

Thanks in advance…


Not sure what exactly it is you need, but Gii has a form generator, in which you can either use CDetailView or CGridView.

You can create a model for a MySQL view by overriding the primaryKey() method. As it seems that your view is not updateable, you won’t be able to save any records.

Thanks Jose and Igastmans, a combination of both your answers brought the light ;)

–> create a model for a MySQL view

–> CDetailView or CGridView

–> or, in my case, for automatic refresh: LiveGridView extension !! YII guys rock !!

NB: didn’t find the ‘solved’ button ::)

Glad you solved the problem! :)