Error Loading Model in CodeIgniter

1

Hello,

I'm trying to load the model into my controller as follows:

$this->load->model("gerente");

But simply everything after this code does not work, I've already tried loading by passing "Manager" instead of "manager" but the only difference is that in that way appears > "Error 500" .

Here is the Model code I'm trying to call:

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
require_once 'usuario.php';

class Gerente extends Usuario {
    public function __construct() {
        parent::__construct();
    }
}

/* End of file gerente.php  */
/* Location: ./application/models/gerente.php */

User is a class that is calling CI_MODEL . And I'm already loading the database $this->load->database();

    
asked by anonymous 22.03.2015 / 14:13

1 answer

1

Your manager.php file should extend the CI_Model class of CodeIgniter to then load the parent constructor of that class.

//gerente.php Model
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    //require_once 'usuario.php';

    class Gerente extends CI_Model {
        public function __construct() {
            parent::__construct();
        }
        //TODO here
    }

//home.php Controller
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');     
    class Home extends CI_Controller {
        public function __construct() {
            parent::__construct();
            $this->load->model('gerente'); // ou no autoload do config.php ou em cada método.
        }
        //TODO here
    }
    
22.03.2015 / 14:51