Kohana ORM“主要值”
我一直在阅读 Kohana ORM 的文档,在他们的示例模型类中,它有一个代码块,如下所示:
protected $_table_name = 'strange_tablename'; // default: accounts
protected $_primary_key = 'strange_pkey'; // default: id
protected $_primary_val = 'strange_name'; // default: name (column used as primary value)
显然我知道表名和主键是什么,但我以前从未见过使用过的术语“主值”,它到底是用来做什么的?
I've been reading through the documentation for Kohana ORM and in their example model class it has a block of code like:
protected $_table_name = 'strange_tablename'; // default: accounts
protected $_primary_key = 'strange_pkey'; // default: id
protected $_primary_val = 'strange_name'; // default: name (column used as primary value)
Obviously I know what table name and primary key are but I've never seen the term "primary value" used before, what exactly is it used for?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
$_primary_val
命名表中的另一列,您可以选择将其用作更用户友好的标识符。因此,如果您的用户将 69113 这样的整数值视为真正的主键感到困惑,您可以提供不同的值,例如“波塞冬冒险”。http://docs.kohanaphp.com/libraries/orm#primary_val
The
$_primary_val
names another column in the table that you can optionally use as a more user-friendly identifier. So if it's confusing for your users to see integer values like 69113 as the real primary key, you can present a different value like "The Poseidon Adventure".http://docs.kohanaphp.com/libraries/orm#primary_val
$_primary_val 属性在 v2.3.4 中很有用(ORM 有一个 select_list() 方法) 。 ORMv3 中还没有这样的方法。
$_primary_val property was useful in v2.3.4 (ORM has a select_list() method). There is no such method in ORMv3 (yet).