Answer the question
In order to leave comments, you need to log in
How to properly inherit models in Yii?
There are 2 tables - t_product and t_service , they have the same fields: name, price, etc. I created models and generated CRUD. I did this, moved the repetitive code to the Craft class.
And I got 2 neat classes:class Craft extends CActiveRecord{ ....
class Service extends Craft
{
public $imagePath = 'images/service';
public function tableName()
{
return 't_service';
}
}
class Product extends Craft
{
public $imagePath = 'images/product';
public function tableName()
{
return 't_product';
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question