-
Book Overview & Buying
-
Table Of Contents
Yii Application Development Cookbook - Second Edition - Second Edition
Data providers are used to encapsulate common data model operations such as sorting, pagination, and querying. They are used with grids and lists extensively. Because both widgets and providers are standardized, you can display the same data using different widgets and you can get data for a widget from various providers. Switching providers and widgets is relatively transparent.
Currently CActiveDataProvider, CArrayDataProvider, and CSqlDataProvider are implemented to get data from Active Record models, arrays, and SQL queries respectively. Let's try all these providers to fill a grid with data.
Create a new application using yiic webapp as described in the official guide.
Download the Sakila database from http://dev.mysql.com/doc/index-other.html and execute the downloaded SQLs (first schema then data).
Configure the database connection in protected/config/main.php.
Use Gii to create a model for the film table.
Let's start with a view for a grid...
Change the font size
Change margin width
Change background colour