No, because in order to call User::model() and get back a User instance you need to define the static model() function within User.php because PHP can’t handle static inheritance (http://socket7.net/a…and-inheritance). Therefore I would have to define this following method within ALL model classes;
<?php
class User extends CActiveRecord
{
public static function model($className = __CLASS__)
{
return parent::model($className);
}
}
class Post extends CActiveRecord
{
public static function model($className = __CLASS__)
{
return parent::model($className);
}
}
?>
I don't like to repeat myself, so that's why I created the component. You might come back and say why not just do:
<?php
$user = CActiveRecord::model('User');
?>
But, I don't want to have to bother knowing which of my models are of type CActiveRecord or CModel (like CFormModel instance) or heck, even if a model is a plain old object.