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

Hi.

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.

thanks.

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





public function scopes()

    {

        return array(

            'published'=>array(

                'condition'=>'status=2',

            ),

            'recently'=>array(

                'order'=>'create_time DESC',

                'limit'=>5,

            ),

        );

		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(){

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

     	//this is the right place

	}