Simple extension that can be used to apply scopes to a CActiveDataProvider
Resources ¶
Documentation ¶
Requirements ¶
- Yii 1.0 or above
Installation ¶
- Extract the release file under protected/extensions
Usage ¶
See the following code example:
$dataProvider=new EActiveDataProvider('Post', array(
   'scopes'=>array('published'),
   'criteria'=>array(
      //'condition'=>'status=1 AND tags LIKE :tags',
      //'params'=>array(':tags'=>$_GET['tags']),
      'with'=>array('author'),
   ),
   'pagination'=>array(
      'pageSize'=>20,
   ),
));
$dataProvider->joinAll = true; // optional if you want to also join the *_MANY relations
$dataProvider->getData(); // will return a list of Post objects
Change Log ¶
September 7, 2010 ¶
- Update to make it work with Yii 1.1.4March 19, 2010 ¶
- Initial release.
very useful!
thanks!
Easy to use and very effective
I installed this a few days ago and it has simplified things tremendously for me.
I'm very curious why scopes weren't implemented by default -- is there a major performance hit when you're working with very large dataproviders?
Applying scopes without extended data provider
You can do it without extensions:
$dataProvider=new CActiveDataProvider(Post::model()->published());
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.