简体   繁体   English

登录和注册的COdeIgniter结构

[英]COdeIgniter structure for login & registration

I am creating a login & registration system using CodeIgniter. 我正在使用CodeIgniter创建登录和注册系统。

Currently I have a Model, View and Controller for login, with functions to validate, check username, etc and an registration model, view and controller, that does the registration. 目前,我有一个用于登录的模型,视图和控制器,具有用于验证,检查用户名等的功能,以及用于注册的注册模型,视图和控制器。

I have chosen to separate the login and registration as a principle. 我选择将登录和注册分开作为原则。

So right now i need to include functions to edit profile, and to check if logged in or not, and to check the user's role, and I would like to know how can i best do this, i have planned creating a user model and controller(no view), the main user controller would have the methods call to model's, but however the methods(updateprofile,islogin,etc) would be in different models, for example in the login model. 因此,现在我需要包括用于编辑配置文件,检查是否已登录以及检查用户角色的功能,并且我想知道如何最好地做到这一点,因此我计划创建一个用户模型和控制器(无视图),主用户控制器可以调用模型的方法,但是方法(updateprofile,islogin等)将处于不同的模型中,例如在登录模型中。

So is this design good/bad? 那么这个设计好/坏吗? How can it be done better. 如何做得更好。 I would appreciate your suggestion's. 非常感谢您的建议。

I really find no problem with your application structure. 我真的发现您的应用程序结构没有问题。 Its how you write your code and how will it easily be to update it in the future. 它是您如何编写代码以及将来如何轻松地对其进行更新。 For managing your models try using an ORM. 为了管理模型,请尝试使用ORM。 PHPActiveRecord is a good start. PHPActiveRecord是一个好的开始。 With this, you no longer be creating alot of individual functions for your database transactions. 这样,您就不再需要为数据库事务创建很多单独的功能。 Reference 参考

You can create a User_Model and expand it as needed. 您可以创建一个User_Model并根据需要展开它。 You can see this CI auth lib for example as how build login & registration structure in CodeIgniter. 您可以看到此CI身份验证库 ,例如如何在CodeIgniter中构建登录和注册结构。

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

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