AR scopes working with find/findAll [solved]

[s]hi there,

I hope that working with scopes and find/findAll can more flexible together with dbcriteria. When did a test on these codes, it seems like the criteria in scopes and the criteria parameterize in findAll are not merged when querying. Please tell me if there is a way to be done.

Thank you.

Example:

In CActiveRecord:




public function scopes() {

  return array(

    'published' => array(

      'condition' => 't.deleted IS NULL',

      'limit' => 100,

      'order' => 'name DESC',

    ),

  );

}






$criteria = new CDbCriteria();

$criteria->offset = 10;

$records = Post::model()->published()->findAll($criteria);



[/s]

They should be merged, see implementation of __call() in CActiveRecord.php. What was your test? Can you show some simple SQL?

Maybe also check the source of mergeWith() implementation in CActiveRecord.php to find out how the merge is done.

I am sorry. It does work. I think I just got mixed up by the other trace logs.