douan8473
2012-02-22 07:53
采纳率: 100%
浏览 15
已采纳

在kohana中扩展ORM用户模型

I'm new to Kohana and I'm trying to build an application using the ORM module. I created my own user module containing stuff like login, account creating etc. The problem however is that I can't seem to create a user model in my own user module extending the ORM one. If I understand kohana correctly I should name my user model: Model_User. The problem is, the ORM model I'm trying to extend is also called Model_User.

The reason I'm trying to create my own model is so I can add some extra methods and checks without modifying with the ORM user model. So my question is:

How do I create a user model in my own module that extends the ORM user model?

图片转代码服务由CSDN问答提供 功能建议

我是Kohana的新手,我正在尝试使用ORM模块构建应用程序。 我创建了自己的用户模块,其中包含登录,帐户创建等等。但问题是我似乎无法在我自己的用户模块中创建用户模型来扩展ORM。 如果我正确理解kohana,我应该命名我的用户模型:Model_User。 问题是,我试图扩展的ORM模型也称为Model_User。

我试图创建自己的模型的原因是我可以添加一些额外的方法和检查,而无需使用ORM用户模型进行修改。 我的问题是:

如何在我自己的模块中创建扩展ORM用户模型的用户模型?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongqi8863 2012-02-22 09:48
    已采纳

    You can extend pretty much everything in Kohana via the transparent class extensions: http://kohanaframework.org/3.2/guide/kohana/extension

    In this case, the default ORM Model_User class is an empty (transparent) class that extends Model_Auth_User.

    So if you want to add new methods to this model, just create a new Model_User model class that extends Model_Auth_User, in your module.

    Due to Kohana's cascading file system, the model stored in your module will be used. http://kohanaframework.org/3.2/guide/kohana/files

    [edit] Important to note, the order in which you enable the modules is important, see http://kohanaframework.org/3.2/guide/kohana/modules

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题