kohana add column to inherit model

296 Views Asked by At

I was wondering how to work with kohana orm and inheritances.

Supose I have a model called Vehicle

$_table_columns with 5 columns

The lets supose I create another model called Car and I want to add 5 more columns to the model. How should I modify the parent $_table_columns variable or should I override it?

Thanks

1

There are 1 best solutions below

4
On

I suppose you're looking for something like this protected $_table_columns = parent::_table_columns + array(...);. Unfortunatly PHP won't allow for this, so you will have to either override $_table_columns and list all 10 columns or override ORM reload_columns method like this:

public function reload_columns($force = FALSE)
{
   $this->_table_columns = parent::_table_columns + array(...);
   parent::reload_columns($force);
}