[s]What exactly is the intended purpose of the static CActiveRecord::model() method?
In the documentation and examples, it’s always used when demonstrating how to build a query… however…
<?php
// find active users:
$users = User::model()->active()->find();
// find inactive users:
$users = User::model()->inactive()->find();
… because the static model() method always returns the same instance, in the second query, you are actually working with the same CDbCriteria instance - which results in a search for users that are active() AND inactive(), i.e. no results.
I thought I might have to call resetScope() before each query to work around this, but that doesn’t work either, since you would be throwing away your defaultScope() criteria.
Is there a defined way to start a new query? I don’t see one.
If the static model() method is going to result in weird buggy edge-cases whenever two queries are executed against the same model during the same request, I don’t want to use it - and if that’s the case, I don’t understand why the documentation and tutorials teach you to do this? It seems dangerous, and wrong.
Any ideas?[/s]