In my application, i have fields that are common to all tables, like create date, update date etc. To assign these values i’m using beforeValidate callback. Now, this callback is same for all models.
To avoid code duplication, i want to create a base model class.
But, when I tried to create a base model, yii thrown error saying table cannot be found in database, which is true since I dont have any table for this base model.
Is there any way I can create a base model class.
Take a look at CTimeStampBehavior.
Incase that doesn’t help you, you can just write a behavior class yourself.
Hope this helps.
Edit:
Assuming you are using ActiveRecords.
If you want to create a new base model, you can do this: