See my post here for need:
My solution is to implement named models as follows:
in CActiveRecord
public static function namedModel($modelName)
{
if(isset(self::$_models[$modelName]))
return self::$_models[$modelName];
else
{
$currentModel = static::model();
$className = get_class($currentModel);
self::$_models[$className] = null;
$newModel = self::model($className);
self::$_models[$className] = $currentModel;
self::$_models[$modelName] = $newModel;
return $newModel;
}
}
In my controller:
$activeUsers = new CActiveDataProvider(User::namedModel('a')->whereActive(1));
$inactiveUsers = new CActiveDataProvider(User::namedModel('b')->whereActive(0));
Thoughts? I think having named models would provide a lot of value to the idea of scopes.