Yii 1.1: active-data-provider-with-scopes

Use scopes in CActiveDataProvider

Simple extension that can be used to apply scopes to a CActiveDataProvider




  • Yii 1.0 or above


  • Extract the release file under protected/extensions


See the following code example:

$dataProvider=new EActiveDataProvider('Post', array(
      //'condition'=>'status=1 AND tags LIKE :tags',
$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.4

March 19, 2010

  • Initial release.

Total 3 comments

#4699 report it
Nayjest at 2011/08/05 04:35am
Applying scopes without extended data provider

You can do it without extensions: $dataProvider=new CActiveDataProvider(Post::model()->published());

#123 report it
thorfinn at 2010/09/05 07:19am
very useful!


#655 report it
Dana at 2010/03/27 02:12pm
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?

Leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: New BSD License
  • Developed by: Troto
  • Category: Database
  • Votes: +5
  • Downloaded: 1,287 times
  • Created on: Mar 19, 2010
  • Last updated: Oct 4, 2010