how to load database in helper?

$CI = get_instance();

$CI->load->database(‘db’);

$CI->db->select(‘*’);

$CI->db->from(TBL_INVENTORIES.’ p’);

$CI->db->where(‘p.product_id=4050’);

$CI->db->order_by(‘p.id’,’desc’);

Asked on February 12, 2020 in Codeigniter.
Add Comment
3 Answer(s)

Are you missing¬† “&”

$CI =& get_instance();

Answered on February 13, 2020.
Add Comment

I tried with even “&” but still its same

Answered on February 14, 2020.
Add Comment

Best practice to autoload db.. instead loading manually all the places. Just define in autoload file.  Rest it will take care of itself.

Answered on June 27, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.