title: Object oriented schemes for Codeigniter
body: <p>I want to be clear on this one. I am using codeigniter.</p>
  
  <p>What/Which is the better/proper/standard/most appreciated way of OOP design in codeigniter in building web applications?</p>
  
  <p>Generally,</p>
  
  <p>I. <strong>Creating a custom class like User and have a login function?</strong> Like,</p>
  
  <pre><code>     class User{ 
              var $db, $id, $username, $password, $role; //have all user attributes here
  
              function __construct() {
                 //instance for accessing the database
                 $this-&gt;db =&amp; get_instance();
              }
  
              public function login(){
                  //do the login here
                  $this-&gt;db-&gt;load-&gt;model('user_model');   
                  $success = $this-&gt;db-&gt;user_model-&gt;login($this-&gt;username, $this-&gt;password);      
                  //isn't this redundant using models? or should I rename the model function name like checkLogin?
                  return $success;
              }
  
              //other class functions 
          }
  </code></pre>
  
  <p>OR</p>
  
  <p>II. <strong>Directly calling a login function in the model from the controller without creating a user object?</strong></p>
  
  <p>O_o</p>
  
  <p>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. 
  <strong>BUT</strong> i feel a redundancy in my login function where I called another login function in the model. Is this good?</p>
  
  <p>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?</p>
  
  <p>I really need some guide. 
  My OO skills needs to grow.</p>
  
  <p>Thank you so much!</p>