Below is my helper function(defined in autoload as db)
<?php
function get_categories_h(){
$CI = get_instance();
$categories = $CI->Product_model->get_categories();
return $categories;
}
function in model is
public function get_categories(){
$this->db->select('*');
$this->db->from('categories');
$query = $this->db->get();
return $query->result();
}
code in the view is
<?php foreach(get_categories_h() as $category) : ?>
<li class="list-group-item"><a href="#"><?php echo $category->name; ?></a></li>
<?php endforeach; ?>
error I am getting is
Message: Undefined property: Products::$Product_model
Filename: helpers/db_helper.php
Fatal error: Call to a member function get_categories() on a non-object in C:\xampp\htdocs\gamingplace_done\application\helpers\db_helper.php