Author Topic: how to retrive data from database..  (Read 5383 times)

Offline pratik_1712

  • Jr. Member
  • **
  • Posts: 43
how to retrive data from database..
« 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

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,879
    • SKaero - Custom Roundcube development
how to retrive data from database..
« Reply #1 on: January 20, 2011, 06:21:46 AM »
Why don't you post the query your using and the error your getting.

Offline pratik_1712

  • Jr. Member
  • **
  • Posts: 43
how to retrive data from database..
« Reply #2 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..??

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
how to retrive data from database..
« Reply #3 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);
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline pratik_1712

  • Jr. Member
  • **
  • Posts: 43
how to retrive data from database..
« Reply #4 on: January 22, 2011, 07:31:30 AM »
@rosali : thanks that solved it..:)