Welcome Guest, Not a member yet? Register   Sign In
I need help

I have only started using Codeigniter and i love it!
I have found that in my controllers i am using the same functions over and over. So i thought build a custom library and then i can use that.
here is my code

class Mygeodata
    var $CI;
    function Mygeodata()
        $CI =& get_instance();
    function get_countries()
        $query = $this->CI->query('SELECT `con_id`,`name` FROM `vb_geo_countries` ORDER BY `name`');
        foreach($query->result() as $row)
            $country_list .= '<option value="' . $row->con_id . '">' . $row->name . '</option>';
        return $country_list;

when i run this it gives me this error...
Call to a member function query() on a non-object
what am i doing wrong?

Thank you in advance!

It will be

Thanks but still no go

i have tried
no luck

The above gives this error
Severity: Notice
Message: Undefined variable: CI
Filename: libraries/Mygeodata.php
Line Number: 15

$this->CI =& get_instance();

in constructor. I missed it earlier.

That was it,
Thank you so much! Gonna save me a lot of time retyping all the functions for each controller!!!!!

Thanks Again!

Theme © iAndrew 2016 - Forum software by © MyBB