<?php

/**
 * Class that operate on table 'playstationclientcard'. Database Mysql.
 *
 * @author: http://phpdao.com
 * @date: 2021-06-24 11:58
 */
class PlaystationclientcardMySqlExtDAO extends PlaystationclientcardMySqlDAO {

    public function queryAllByQueryString($queryString = '') {
        $sql = 'SELECT playstationclientcard.*,playstationcard.name as cardName,client.clientname
            FROM playstationclientcard
            join playstationcard on playstationcard.id = playstationclientcard.cardid
            join client on client.clientid = playstationclientcard.clientid
            where 1 ' . $queryString;
        $sqlQuery = new SqlQuery($sql);
        return $this->getList($sqlQuery);
    }

    public function getClientPSCards($clientId, $queryString = '') {
        $sql = 'SELECT playstationclientcard.*,playstationcard.name as cardName
            FROM playstationclientcard
            join playstationcard on playstationcard.id = playstationclientcard.cardid
            where  playstationclientcard.del=0 and playstationclientcard.cardStatus = 0 and date(cardEndDate) >= "' . date('Y-m-d') . '" and clientid=' . $clientId . ' ' . $queryString;
        $sqlQuery = new SqlQuery($sql);
        return $this->getList($sqlQuery);
    }

    public function getExpiredPSCards($queryString = '') {
        $sql = 'SELECT playstationclientcard.*
            FROM playstationclientcard
            where playstationclientcard.del=0 and playstationclientcard.cardStatus = 0 and date(cardEndDate) < "' . date('Y-m-d') . '" ' . $queryString;
        $sqlQuery = new SqlQuery($sql);
        return $this->getList($sqlQuery);
    }

}

?>