Welcome Guest, Not a member yet? Register   Sign In
Error - "Call to a member function on a non-object" - Any ideas?
#1

[eluser]invision[/eluser]
Hi,

I'm getting this error on this function:

"Call to a member function on a non-object".

I have marked in the code where the issue arises.


Code:
<?php
class MPages extends Model{

    function MPages(){
        parent::Model();
    }

    function getPageBySlug($slug){
        $data = array();
        **** $this->db->where('slug',$slug); ****
        $this->db->limit(1);
        $Q = $this->db->get('pages');
        if ($Q->num_rows() > 0){
          $data = $Q->row_array();
        }
        $Q->free_result();    
        return $data;    
    }

I'd love to get some help with this. Planned to make a decent dent on a project today and fallen at the first Sad


Many thanks for any ideas.
#2

[eluser]JoostV[/eluser]
Try loading the database class.
Code:
$this->load->database();
#3

[eluser]invision[/eluser]
Many thanks Joost! All sorted now.




Theme © iAndrew 2016 - Forum software by © MyBB