yii - How to extend cactiverecord -
i want add aditional methods in cactiverecord, if class project_model extends cactiverecord {} error
the table "project_activerecord" active record class "project_activerecord" cannot found in database.
i want create simple structure: cactiverecord->project_activerecord (only extend methods)->table (real table).
how can this?
the error clear: don't have table named project_activerecord in db!
if project_model going base model others active record models should like:
//a base classe example has behavior shared inherited class abstract class project_model extends cactiverecord { public function behaviors(){ return array( 'ctimestampbehavior' => array( 'class' => 'zii.behaviors.ctimestampbehavior', 'setupdateoncreate' => true ), ); } } and can declare other class will have table in db:
class yourclass extends project_model { /** * returns static model of specified ar class. * @param string $classname active record class name. * @return token static model class */ public static function model($classname=__class__) { return parent::model($classname); } /** * @return string associated database table name */ public function tablename() { return 'yourclasstable'; } ... } then shoudl never call class project_model (this why put keyword abstract) in code, have call inherited classes have existing table in db!
Comments
Post a Comment