Roundcube Community Forum

Miscellaneous => Roundcube Discussion => Topic started by: pratik_1712 on January 20, 2011, 04:29:18 AM

Title: how to retrive data from database..
Post by: pratik_1712 on January 20, 2011, 04:29:18 AM
I want to retrieve the details of current user from the "users" table.

How can this be achieved..??
having a little trouble fetching value from mysql..??
help with the syntax
or
redirect to proper resource..

Thanks and Regards..
Pratik
Title: how to retrive data from database..
Post by: SKaero on January 20, 2011, 06:21:46 AM
Why don't you post the query your using and the error your getting.
Title: how to retrive data from database..
Post by: pratik_1712 on January 21, 2011, 01:12:08 AM
$rcmail = rcmail::get_instance();
$curr = $rcmail->db->query("
            SELECT username FROM ".get_table_name('users')."
            WHERE  user_id=?",
            $rcmail->user->ID);

and now the value of $curr is 3..
isn't it suppose to return the user-emailid..??
or is there any other method to execute the queries..??
Title: how to retrive data from database..
Post by: rosali on January 21, 2011, 10:18:49 AM
... $curr is the resource id ... you need to fetch the entries ...

while($email = $rcmail->db->fetch_assoc($curr))
  $emails[] = $email;

print_r($emails);
Title: how to retrive data from database..
Post by: pratik_1712 on January 22, 2011, 07:31:30 AM
@rosali : thanks that solved it..:)