kohana专栏自省

编程入门 行业动态 更新时间:2024-10-07 20:30:56
本文介绍了kohana专栏自省的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道KOHANA模型上$ _table_columns数组的功能是什么.

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?

推荐答案

$_table_columns反映了您的表列结构.因此,如果您的表有3列(id,name,desc),则将$_table_columns设置为array('id' => '', 'name' => '', 'desc' => '').

$_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' => '').

默认情况下,$_table_columns是一个空数组.当使用类扩展ORM且不覆盖$_table_columns时,ORM将通过调用SHOW FULL COLUMNS FROM table_name命令自动将其填充.如果要避免此额外的数据库调用,可以自行初始化$_table_columns:

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' => ''); }

在此处中查看有关详情.

更多推荐

kohana专栏自省

本文发布于:2023-11-02 06:18:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551598.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:专栏   kohana

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!