How to use site.inc.php

Discussion in 'aMember Pro v.4' started by incirus, Nov 25, 2013.

Thread Status:
Not open for further replies.
  1. incirus

    incirus New Member

    Joined:
    Feb 27, 2012
    Messages:
    21
    Hi,

    My version is 4.3.5
    I am trying to run a custom query within the template. application/default/themes/mytemplate/layout.phtml
    I don't want to use regular php mysql query with the db login and I'm trying to us amember's
    Code:
    global $db;
    I tried to use site.inc.php too. I tried to follow this page but so far no luck.
    http://manual.amember.com/Using_site.inc.php_and_hooks

    Can you guys give me an example of a custom query from site.inc.php and usage of this query in my template?

    Thanks in advance.
  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    There is not global objects in aMember 4. You can execute SQL query the following way inside your template:

    Code:
    $di->db->query("SELECT * FROM ?_user WHERE user_id=? AND login=?", 15, 'login');
    ?_ mark will be automatically replaced with your teble prefix (am_ in most cases). You can use ? as placeholder for values. Values will be properly escaped in final query.
  3. incirus

    incirus New Member

    Joined:
    Feb 27, 2012
    Messages:
    21
    thanks caesar, it worked.
  4. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    You are welcome!
Thread Status:
Not open for further replies.

Share This Page