Filled out like this it will generate a set of classes such as
application.models.db.base.CustomerBase
application.models.db.base.CustomerAddressBase
You’d then extend/inherit from these to create
application.models.db.Customer
application.models.db.CustomerAddress
If you update columns/headers in your customer table you can regenerate the code in the base class without erasing your custom code in the actual model class.
I’ve even done a separate inheritance from the base class for searching as follows:
//generated, placed in application.models.db.base
class ProductBase extends CActiveRecord
{
...
}
//inherited, placed in application.models.db
class DistrictBase extends CActiveRecord
{
public static function model($className=__CLASS__)
{
return parent::model($className);
}
//other custom functions, or overrides such as
public function attributeLabels()
{
return CMap::mergeArray(array('customColumn'=>'Custom Column'),parent::attributeLabels() );
}
}
//inherited, placed in application.models.db.search
class ProductSearch extends ProductBase
{
public static function model($className=__CLASS__)
{
return parent::model($className);
}
public function __construct($scenario='search')
{
parent::__construct($scenario);
}
protected function afterConstruct()
{
parent::afterConstruct();
$this->unsetAttributes();
}
// other custom search functions or columns that aren't really on the model
}