db query

Discussion in 'Troubleshooting' started by csongor_simsay, Sep 20, 2016.

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

    csongor_simsay New Member

    Joined:
    Dec 10, 2013
    Messages:
    26
    Hi,
    I'm trying to collect users in an array, who have paid but expired more than a year ago:

    $user_ids = Am_Di::getInstance()->db->selectCol(select member_id from amember_payments where expire_date <='2015-12-31' and completed=1);

    Can you advise?
  2. csongor_simsay

    csongor_simsay New Member

    Joined:
    Dec 10, 2013
    Messages:
    26
    the help support solved the problem, I copy here it may be useful for others too:
    (users in an array, who have not paid since 1 year)

    $user_ids = Am_Di::getInstance()->db->selectCol(<<<CUT
    SELECT user_id, MAX(dattm) AS d
    FROM am_invoice_payment
    GROUP BY user_id
    HAVING d < DATE_SUB(CURDATE() , INTERVAL 1 YEAR);
    CUT
    );
Thread Status:
Not open for further replies.

Share This Page