Amember Database help

Discussion in 'Integration' started by tsongkie, Dec 28, 2009.

  1. tsongkie

    tsongkie New Member

    Joined:
    Dec 28, 2009
    Messages:
    6
    Hi can anyone point me to the proper direction? What I'm trying to do is run a sql/database query from a desktop software and check if the member has an active subscription for products 1, 2 and 3. What would the sql command be?
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Check if user have active subscription for product 1
    Code:
    select count(*) from amember_payments where member_id=ID_OF_USER and completed=1 and product_id=1 and begin_date<=now() and expire_date>=now()
    
    Check if user have active subscription for product 1 or product 2 or product 3
    Code:
    select count(*) from amember_payments where member_id=ID_OF_USER and completed=1 and product_id in (1,2,3) and begin_date<=now() and expire_date>=now()
    
    The same based on user's login:
    Code:
    select count(*) from amember_members m left join amember_payments p on m.member_id = p.member_id where m.login='LOGIN_OF_USER' and p.product_id =4 and p.completed =1 and p.begin_date <=now() and p.expire_date >=now()
    

Share This Page