2

Can any one please explain me what are all the best scenario to use particular dataprovider.

For ex :

  • When to use CActiveDataProvider ? (pros and cons)

  • When to use CArrayDataProvider ? (pros and cons)

  • When to use CSqlDataProvider ? (pros and cons)

Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
deepan raj
  • 21
  • 1
  • This links may helpful to this topic http://www.fasw.ws/faswwp/yii-retrieve-data-with-any-dataprovider/ http://www.yiiframework.com/forum/index.php/topic/12066-no-data-object-with-csqldataprovider-or-carraydataprovider/ – gvgvgvijayan Apr 30 '15 at 05:42

1 Answers1

1
  1. CActiveDataProvider - Use this if you have a list of models (uses findAll()).
  2. CArrayDataProvider - Use this when you have a raw array of objects which is not a list of models.
  3. CSqlDataProvider - Use this when you have a database query resulting in a list of objects and not a list of models.

You can use all three of them to construct html with for example the (default) widgets.

The docs are quite clear on when and how to use the three:

  1. CActiveDataProvider
  2. CArrayDataProvider
  3. CSqlDataProvider
Jelle de Fries
  • 885
  • 1
  • 11
  • 20