Question

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

Was it helpful?

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top