Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8072473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:01:39+00:00 2026-06-05T14:01:39+00:00

I want to be clear on this one. I am using codeigniter. What/Which is

  • 0

I want to be clear on this one. I am using codeigniter.

What/Which is the better/proper/standard/most appreciated way of OOP design in codeigniter in building web applications?

Generally,

I. Creating a custom class like User and have a login function? Like,

     class User{ 
            var $db, $id, $username, $password, $role; //have all user attributes here

            function __construct() {
               //instance for accessing the database
               $this->db =& get_instance();
            }

            public function login(){
                //do the login here
                $this->db->load->model('user_model');   
                $success = $this->db->user_model->login($this->username, $this->password);      
                //isn't this redundant using models? or should I rename the model function name like checkLogin?
                return $success;
            }

            //other class functions 
        }

OR

II. Directly calling a login function in the model from the controller without creating a user object?

O_o

In scheme 1, I am making the model to query ONLY in the database.
I can also make ‘User’ object to be inherited like for ‘Client’, ‘Admin’ and add specific functions for each object. I have the advantage to make the CI controller to focus in the layout and passing of variables to the view, which is primarily its purpose(not quite sure) and let the my custom classes/objects tackle operations in my web app.
BUT i feel a redundancy in my login function where I called another login function in the model. Is this good?

While in scheme 2, is it proper to let my controllers handle all operations like login, register, or create a log AND receiving input posts and passing of variables to the view?

I really need some guide.
My OO skills needs to grow.

Thank you so much!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T14:01:41+00:00Added an answer on June 5, 2026 at 2:01 pm

    Firstly I think it would be useful for you to read this arrticle:

    Access Control List

    I’m working on a project now that uses CodeIgniter and the approach that we are using here maybe will suit you too. If you need to check for authorisation, I think the best place to do this is in the constructor of the class with calling a login function if the user is not registered yet. But it is a little bit general approach so if you have classes where some functions should be available only to registered users then you should make the check inside the function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can't seem to achieve this simple functionality! All I want is to clear a
I want to clear textbox after ajax posting. <div style=padding: 5px; background-color: Silver;> @using
I want to clear textbox after ajax posting. <div style=padding: 5px; background-color: Silver;> @using
I am using extjs textfield in one of the grids in a webpage. This
I am storing data in application scope. I want to clear this data after
I can clear all the layers using mapControl.ClearLayers(), but I only want to clear
I want to clear localStorage for my app each time I install it from
i want to clear specified input if the value is not number. function works
i want to clear the fields of my form after the user has inserted
I want to clear the contents of some std::list . The order of removing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.