Here is an example of how you would use this User subclass.
1. $record=new User;
2. $record=User::model()->findByPk((int)$id);
If you use example 1, all your custom methods in User along with rules, etc work just fine. However if you use example 2 what you get back from model() appears to be an instance of UserBase so you're losing the benefits of subclassing off of UserBase. Here's what I did to get around this issue. Add the following to your subclass.
/**
* @return object of current class instead of reverting to parent class
*/
public static function model($className=__CLASS__)
{
$model=new $className(null);
$model->_md=new CActiveRecordMetaData($model);
$model->attachBehaviors($model->behaviors());
return $model;
}
I'm using PHP version 5.2 on Windows. I don't know if this will addressed in future versions of Yii. The code in my method came from Yii's source so I can't even explain it in full detail at the moment. All I can say is that the rules and methods in my subclass work like they are supposed to. Please feel free to share any comments/concerns about this.