Codeigniter Help

 Load Database

Go to autoload.php in application/config/autoload.php and add this

$autoload['libraries'] = array('database'); // add database in array(now you dont need to load database at anywhere in project)

Make database connection settings in database.php, file located atapplication/config/database.php

now try this

 class Users_model extends CI_Model {
  function __construct() {
    parent::__construct();
    //$this->load->database(); <----remove this
  }

  public function get_all_users() {
    return $this->db->get('users');
  }
}


Post a Comment

0 Comments