I basically implemented such class. It uses common pool in ARPool class for all children classes (another option is to have such pool property in every child class, but I like this option because it's more centralized and you don't need to change your final classes at all). This is the key part:
class ARPool extends CActiveRecord
{
private static $_pool = array();
public static function registerRecord(ARPool $record)
{
$class = get_class($record);
$pkAttr = $record->getMetaData()->tableSchema->primaryKey;
if (!isset(self::$_pool[$class]))
self::$_pool[$class] = array();
self::$_pool[$class][$record->$pkAttr] = $record;
}
/* There are overridden CActiveRecord methods: populateRecord(), findByPk(), etc. */
}
All you need is to change "class Comment extends CActiveRecord" to "class Comment extends ARPool" and it works the same way.
This also have a side effect I consider positive: every model is always the same object, no matter where it was raised.
$c1 = Comment::model()->findByPk(135); $c2 = Comment::model()->findByPk(135); echo $c1->content; // prints "Old value" $c1->content = "New value"; echo $c2->content // prints "New value"
This idea is not somethig big, of course, but I never saw this working with Active Record before. I assume there may be some pitfalls I don't see. Critique and comments are welcome.
Also I can place it to github if anyone is interested.

Help












