Model() Static Method Implementation For Cmodel?

I have been forced to replace the usage of CActiveRecord with CModel (and DAO) because I am connecting to Sybase, for which I haven’t the time to write a schema driver for.

Anyways, as I have been modifying my previously working code (originally used MySQL), I noticed how useful the static method model() CActiveRecord offers is. Why isn’t there a similar static method for CModel?


* Returns the static model of the specified AR class.

* The model returned is a static instance of the AR class.

* It is provided for invoking class-level methods (something similar to static class methods.)


* EVERY derived AR class must override this method as follows,

* <pre>

* public static function model($className=__CLASS__)

* {

* return parent::model($className);

* }

* </pre>


* @param string $className active record class name.

* @return CActiveRecord active record model instance.


public static function model($className=__CLASS__)



return self::$_models[$className];



$model=self::$_models[$className]=new $className(null);

$model->_md=new CActiveRecordMetaData($model);


return $model;



I could extend CModel, add the method, and then base all of my other classes off of this instead of CModel, in order to include the functionality of calling the static class. But I am wondering if this is an appropriate approach or if this is already implemented and I am just not aware of it?