PHP Kohana3。我可以重命名 ORM 对象属性吗?
我正在使用 Kohana3。 例如我创建实例:$user = ORM::factory('orm_user', $user_id)
之后,我可以使用以下语法获取每列的值:$user->user_login
或 $user->user_password
。
我可以重命名此属性以使其类似于:$user->login
或 $user->pass
吗?
I'm using Kohana3.
For example I create instance:$user = ORM::factory('orm_user', $user_id)
After this I can get value of each column using this syntax: $user->user_login
or $user->user_password
.
Can I rename this properties to get them like: $user->login
or $user->pass
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以在模型中重载神奇的 __set 和 __get 方法:
您编写的任何规则或过滤器仍然需要使用原始列名称。
Yes, you can overload the magic __set and __get methods in your model:
Any rules or filters you write will still need to use the original column names.