0

While trying to access a user class object from codeigniter helper file, its throwing error like Class 'User' not found. My code is something like $u = new User(); $u->get(); I am able to use this in library files but not in helper files. Can somebody help me.

Anusha
  • 281
  • 1
  • 13

1 Answers1

1

In order to use model in helper you have to:

// Get a reference to the controller object
$CI = get_instance();

// You may need to load the model if it hasn't been pre-loaded
$CI->load->model('User');

// Call a function of the model
$CI->User->get();

hope it will help!

sandip
  • 3,279
  • 5
  • 31
  • 54