Fatal error: Call to a member function get_where() on a non-object in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\masterlinkci2\application\site\models\gallery_model.php on line 10
I try this :
Line 10: $query = $this->db->get_where('galleries_pictures',array('pic_id'=> $pic_unique_id));
class Gallery_model extends CI_Model {
public function get_picture($pic_unique_id)
{
$query = $this->db->get_where('galleries_pictures',array('pic_id'=> $pic_unique_id));
return $query->result();
}
}
IN Controller:
public function index()
{
$this->load->helper('url');
$this->load->model('gallery_model');//loads model
$data['pic'] = $this->gallery_model->get_picture($pic_unique_id);//calls to model function
$this->load->view('index',$data);//loads view with data
}
IN view
<?php foreach($pic as $pic_item) { ?> <img src="<?php echo base_url(assets1/images/slider/).$pic_item->pic_item; ?>"> <?php } ?>