0

我想知道 KOHANA 模型上 $_table_columns 数组的功能。

我问这个,因为表的列是通过自省加载的,这个数组有什么用,它是属性的默认值吗?

4

1 回答 1

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.

于 2011-11-05T08:56:13.570 回答