Putting directly into Amember DB

Discussion in 'aMember Pro v.4' started by rked, Oct 22, 2012.

  1. rked

    rked New Member

    Joined:
    Jun 11, 2007
    Messages:
    29
    Hello,
    Does anyone have any php snippets of accessing the
    MySQL database of Amember? We are not able to do it via the API.

    What I want to do is to be able to place additional information into the database that will appear in the dashboard of a specific member. Is this easily done? Has anyone here done it? IF so, can I see your code?

    What Im aimimg for is being able to place information in the database directly and specifically for a member like a link and have it show up in their dashboard. I do have personal content plugin, but it utltimately show links to file to download a file, I simply want to show a link to a web page showing the custom product for specific customer. and maybe add other colums to table such as notes for specific customer.

    Thank you
    Robert
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Hi Robert,

    it is great idea to extend the plugin, we will do it in next version.

    Regarding the question, it is easy to run queries on aMember database:
    PHP:
    $db Am_Di::getInstance()->db// shortcut to DbSimple instance http://en.dklab.ru/lib/DbSimple/
    $db->query("UPDATE ?_user SET newfield=? WHERE user_id=?d",
        
    "newvalue - will be automatically e's'caped!"1234);
    $rows $db->select("SELECT * FROM ?_user WHERE email LIKE ?""%google.com"); // select records to array
    $row $db->selectRow("SELECT * FROM ?_user WHERE user_id=?d"1234); // select first found row to assoc array
    $maxId $db->selectCell("SELECT MAX(user_id) FROM ?_user"); // select first column of first found row
    Another good question - how to detect id of current logged-in user?
    PHP:
    // this works on user-side pages only
    $auth Am_Di::getInstance()->auth// shortcut to Am_Auth_User instance
    $user_id $auth->getUserId(); // return user_id of logged_in customer or NULL if not logged-in
    $user $auth->getUser(); // return User object of logged-in customer or throws exception if user is not logged-in!

Share This Page