Pagination criteria overwrites scope "with" criteria

I have Post model with different scopes. These scopes i’m using as documented. And this code belowe working as i wanted.


    

$posts = Post::model()->myGroup()->status('new')->findAll( ); 



BUT if i add pagination for requested rows as follows:


$criteria = new CDbCriteria;


// Pages

$cnt = Post::model()->myGroup()->status('new')->count();

$pages=new CPagination($cnt);

$pages->pageSize = 15;

$pages->applyLimit( $criteria );




$posts = Post::model()->myGroup()->status('new')->findAll( $criteria ); // notice $criteria !



dynamic scope status … OK

static scope myGroup … NOT OK ( $criteria somehow break this scope)

scopes




	# Dynamic scopes

	# ------------------------------------------------------------

	public function status( $status ) {

		$this->getDbCriteria()->mergeWith(array(

			'condition' => 'status = :STATUS',

			'params'=> array(':STATUS' => $status),

		));


		return $this;

	}


	# Static scopes

	# ------------------------------------------------------------

	public function scopes() {

		return array(

			'myGroup'=>array(

				'with' => array(

					'groups' => array(

						'condition' => 'group_id IN (1,2,3)',

					),

				),

			),

		);

	}



and for more information relation between Post and Group is MANY_MANY:




//Post

'groups'=>array(self::MANY_MANY, 'Group', '_group_post(post_id,group_id)'),



Sumup

Without pagination all works fine. I got limited post list with exactly wanted groups ( through scope myGroup)

Adding pagination criteria to findAll() leads to overwriting existing criteria (and exactly param with).

status scope is not affected and works fine

i have tried to manually get Post model scopes and add to pagination criteria, but with no success. Can’t find anything like this, maybe some know how to do this

bump