Let’s say I have two models, Post and Author.
Post has a named scope, implemented by a method named published().
Author has a named scope, implemented by a method named active().
I can produce a list of published Posts using Post::model()->published()->findAll().
I can produce a list of active authors using Author::model()->active()->findAll().
I can produce a list of Posts with their Authors using Post::model()->published()->with(‘authors’)->findAll().
But now suppose I want to produce a list of published() Posts by active() authors.
It seems that, once you call CActiveRecord::with(), you break the chain and leave your static CActiveRecord instance behind - because with() returns a CActiveFinder instance instead, and you’re now in relational land, thus leaving behind your named scope functions, which are only available on your CActiveRecord instance.
Is there any way to combine named scopes from two different models in a single query?