Search code examples
phpcodeigniterhttp-status-code-503

About CodeIgniter structure


I have a project based on codeigniter. I already have a model that extends some CI_Model class. class Playermodel extends CI_Model . I need to import Playermodel in one of my classes so that I can easily access database without hard coding the connection with php.

However this CI_Model class is making me trouble coz I cannot really find a file with CI_Model class. Also when I import it I get internal server error 503.

What should I do in this case and where can I find this CI_Model class?

Thanks


Solution

  • Your models will typically be loaded and called from within your controller functions. To load a model you will use the following function:

    $this->load->model('Model_name')
    

    The DB connection settings are stored in application/config/database.php you dont need to hardcord it int your files. Then to connect to database

    $this->load->database();

    Read the revelant user_guide model database