Ar Class Cannot Be Used To Make Db Queries In The Method That Declares The Scope


There is a note in yii guide that says:

when declaring a scope (default or named), the AR class cannot be used to make DB queries in the method that declares the scope.

can somebody explain it with an example.


i think it means you can’t use it like this:

public function scopes()


        return array(





                'order'=>'create_time DESC',




		return Post::model()->published()->recently()->findAll();

         / /it will return like this:  Array ( [published] => Array ( [condition] => status=2 ) [recently] => Array ( [order] => create_time DESC [limit] => 5 ) )


	public function test(){


     	//this is the right place