@jasen
To properly call models in CodeIgniter, you would follow these steps:
- Load the model in your controller:
In your controller file, you need to load the model using the load->model() method. Here's an example:
1
|
$this->load->model('User_model');
|
- Use the loaded model in your controller:
Once the model is loaded, you can use its methods in your controller. Here's an example:
1
|
$this->User_model->get_user_info($user_id);
|
In this example, get_user_info()
is a method in the User_model
model that retrieves user information based on the provided $user_id
.
- Access model methods in your views (optional):
You can also access model methods in your views if needed. However, it is recommended to keep business logic in the controller and only pass data to the view.
By following these steps, you can properly call models in CodeIgniter and keep your code organized and maintainable.