Welcome Guest, Not a member yet? Register   Sign In
easy way (!) to convert result of get() into a string?
#1

[eluser]sparbier[/eluser]
I merely want to put the users email-address on the page, so I query the database only for the e-mail field by comparing with the id in the sessions userdata, which results in one single field in one single row.
Now that query result is in the special format of CI, i.e. apparantly I can not directly treat it just as an array (error reads something like "cannot treat CI_DB... as array") or straightforward as a string.

The code below does work, but it looks a bit stupid to me to go through a foreach if I know already that there is only one row.

any suggestions?
Code:
$i = $this->session->userdata('id');
     $this->db->select('email')->from('users')->where('id', $i);
     $me = $this->db->get();
    foreach ($me->result() as $row)
        {
                echo $row->email;
        }


Messages In This Thread
easy way (!) to convert result of get() into a string? - by El Forum - 10-30-2008, 10:36 AM
easy way (!) to convert result of get() into a string? - by El Forum - 10-30-2008, 11:01 AM
easy way (!) to convert result of get() into a string? - by El Forum - 10-30-2008, 11:07 AM
easy way (!) to convert result of get() into a string? - by El Forum - 10-30-2008, 11:55 AM
easy way (!) to convert result of get() into a string? - by El Forum - 10-31-2008, 01:55 AM



Theme © iAndrew 2016 - Forum software by © MyBB