Welcome Guest, Not a member yet? Register   Sign In
Problem with instance of CI database class
#1

[eluser]LuckyFella73[/eluser]
hello all,

I have a problem working with an instance of the CI database class.

I followed a tutorial of "Bramme" -> a basic login class (named "Auth").
In the class (Auth.php) an instance of the database class is loaded:
Code:
# first lines cut
function Auth($props = array())
    {
        $this->CI =& get_instance();
        
        # Load additional libraries, helpers, etc.
        $this->CI->load->library('session');
        $this->CI->load->database();
# rest fo code here

Within one function, I'm able to access my database, for example:
Code:
$this->CI->db->where('vorname', $this->vorname);
        $this->CI->db->where('nachname', $this->nachname);
        $this->CI->db->where('mitgliedsnummer', $this->mitgliedsnummer);
        $this->CI->db->where('geburtsdatum', $this->geburtsdatum);
        
        $query = $this->CI->db->get($this->usertable);

I added a method to the class (a set new password function) and can't access
the db anymore using the same synthax. In the new method I tried:
Code:
$this->CI->db->where('mitgliedsnummer', $this->session->userdata('mitgliedsnummer'));

I just get an error message at this line:
Quote:Fatal error: Call to a member function on a non-object in ...


Any ideas what I'm doing wrong?
#2

[eluser]drewbee[/eluser]
Your error isn't with the database, but the session method call.

Your calling:
Code:
$this->session->userdata('mitgliedsnummer')

Should be
Code:
$this->CI->session->userdata('mitgliedsnummer')
#3

[eluser]LuckyFella73[/eluser]
ähem ... sorry for beeing blind.


thank you Drewbee!
#4

[eluser]drewbee[/eluser]
No worries Smile It seems it's always the easy stuff that is always the hardest to find!




Theme © iAndrew 2016 - Forum software by © MyBB