简体   繁体   English

在kohana中扩展ORM用户模型

[英]Extending the ORM user model in kohana

I'm new to Kohana and I'm trying to build an application using the ORM module. 我是Kohana的新手,正在尝试使用ORM模块构建应用程序。 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. 我创建了自己的用户模块,其中包含登录,帐户创建等内容。但是问题是,我似乎无法在扩展ORM的用户模块中创建用户模型。 If I understand kohana correctly I should name my user model: Model_User. 如果我正确理解kohana,则应将我的用户模型命名为:Model_User。 The problem is, the ORM model I'm trying to extend is also called Model_User. 问题是,我尝试扩展的ORM模型也称为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. 我尝试创建自己的模型的原因是,我可以添加一些额外的方法和检查,而无需使用ORM用户模型进行修改。 So my question is: 所以我的问题是:

How do I create a user model in my own module that extends the ORM user model? 如何在自己的模块中创建扩展ORM用户模型的用户模型?

You can extend pretty much everything in Kohana via the transparent class extensions: http://kohanaframework.org/3.2/guide/kohana/extension 您可以通过透明的类扩展来扩展Kohana中的几乎所有内容: 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. 在这种情况下,默认的ORM Model_User类是扩展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. 因此,如果要向该模型添加新方法,只需在模块中创建一个扩展Model_Auth_User的新Model_User模型类。

Due to Kohana's cascading file system, the model stored in your module will be used. 由于Kohana的级联文件系统,将使用存储在模块中的模型。 http://kohanaframework.org/3.2/guide/kohana/files 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 [edit]请注意,启用模块的顺序很重要,请参见http://kohanaframework.org/3.2/guide/kohana/modules

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM