CodeIgniter Forums
Annoying call to member function on non-object problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Annoying call to member function on non-object problem (/showthread.php?tid=18215)



Annoying call to member function on non-object problem - El Forum - 04-29-2009

[eluser]september28[/eluser]
Sorry if this is really obvious but i have been tearing my hair out trying to figue out what i am doing wrong here...
This is the function in my IdiomSearch_model class

Code:
function search() {
        $terms = $this->input->post('searchterms');
        $this->db->select('idiom, slug');
        $this->db->from('idioms');
        $this->db->where('MATCH (idiom) AGAINST ("'.$terms.'")', NULL, FALSE);
        $query = $this->db->get();
        $result = $query->result();
        if($result) {
            return $result;
        }
        return FALSE;
    }

Basically I call this from a controller and then just load the result into an the $data['searchresults'] to send to the template. When i submit the search form all i get is an error: Fatal error: Call to a member function result() on a non-object in /var/www/idm/system/application/models/idiomsearch_model.php on line 18

Its driving me crazy please help!

Thanks,
Dan


Annoying call to member function on non-object problem - El Forum - 04-29-2009

[eluser]TheFuzzy0ne[/eluser]
It would really help if you told us what was at line 18. Smile


Annoying call to member function on non-object problem - El Forum - 04-29-2009

[eluser]september28[/eluser]
Sorry! Absolutely stupid I am!! I had forgotton to define the field as a fulltext index in mysql. What a plonker!

Dan