Difference between #4 and #5 of
An important tip when you are using CArrayDataProvider.

Changes

Title unchanged

An important tip when you are using CArrayDataProvider.

Category unchanged

Tips

Yii version unchanged

Tags unchanged

CArrayDataProvider

Content changed

Yii ‘'s CArrayDataProvider is very helpful to display model relation data's directly on it.But it is truely a confusing one because by default it will assume a table field named “id” as primary key for its pagination purpose and what if you dont have field named “id” as primary key on your table? so its truely confusing and if you tried to display without an “id” field on ur table you will get an error like “yourmodel.id is not defined”.

To solve this CArrayDataProvider confusing problem you just need to use on of its attribute named “keyField” to specify your primary key field on your table.There is an property named “id” thats just an id of the dataProvider itself.
[...]
Regards,

 
sirin
sirin k
 
 
[Hire Yii developer](https://in.linkedin.com/in/sirink "Hire Yii developer")
5 1
5 followers
Viewed: 19 826 times
Version: 1.1
Category: Tips
Written by: sirin k
Last updated by: Maurizio Domba Cerin
Created on: Sep 1, 2012
Last updated: 6 years ago
Update Article

Revisions

View all history