Search code examples
phpcodeignitercodeigniter-2stdclass

How to get data out of stdclass object?


I am using $this->db->get_where() to get data from database in codeigniter. Its returning following which I got using print_r()

Its looks like array of stdClass object. Anyone who how to access values inside this array.

Array ( [0] =>    
    stdClass Object ( 
    [id] => 1 
    [password321] => qwerty
    [email123] => example@gmail.com 
    [username123] => xyz
    ) 
)

Solution

  • It shows an array of objects. There is only one object in it.

    If:

    $var =  $this->db->get_where();
    

    Then:

    echo $var[0]->id;