0

I would like to know which is the functionality of the $_table_columns array on a KOHANA model.

I ask this since the table's columns are loaded by introspection, what is the use of this array, is it for default values to the properties?

jameslimousin
  • 330
  • 3
  • 11

1 Answers1

0

$_table_columns reflects your table column structure. So if your table has 3 columns (id, name, desc), $_table_columns will be setup to array('id' => '', 'name' => '', 'desc' => '').

By default $_table_columns is an empty array. When you extend ORM with your class and don't override $_table_columns, it will be automatically filled by ORM by calling SHOW FULL COLUMNS FROM table_name command. If you want to avoid this additional DB call, you can initialize $_table_columns on your own:

class Model_User extends ORM {
   protected $_table_columns = array('id' => '', 'name' => '', 'desc' => '');
}

Check here for more details.

Community
  • 1
  • 1
matino
  • 17,199
  • 8
  • 49
  • 58
  • I tried what you said matino, but for example if I add 3 columns to $_table_columns and my table has 4 columns, when I ask for the colum that is not on the array it still brings the value, that is why I have that question, do you know what is that happening? – jameslimousin Nov 06 '11 at 17:02