kohana columns introspection

ε祈祈猫儿з 提交于 2019-12-25 02:22:22

问题


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?


回答1:


$_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.



来源:https://stackoverflow.com/questions/8017337/kohana-columns-introspection

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!