A library is not necessarily part of how CodeIgniter works.
It can be a home library to solve the problem you want to do in your CI application.
This means that if you want to use any CI helpers, models, or other libraries, you need to do this through a CI instance. This is achieved by the fact that:
public function __construct() { $this->CI =& get_instance(); }
By assigning an instance to your member library named CI, all CI-related helpers, models, and libraries can be loaded via $this->CI . Trying to do this only with $this , you only reference the current library, not the CI instance.
To load the model correctly, in your library $this->CI->load->model('model_name'); enough. The second parameter allows you to access your model using a different object name. The third parameter is not needed to load models, but allows you to automatically load the database driver.
If you want to access your model through the same element:
$respone = $this->CI->model_name->method();
Repox
source share