<?php

/**
 * Class that operate on table 'serialsarchive'. Database Mysql.
 *
 * @author: http://phpdao.com
 * @date: 2016-11-20 09:04
 */
class SerialsarchiveMySqlExtDAO extends SerialsarchiveMySqlDAO {

    public function queryAllEX() {
        $sql = 'SELECT serialsarchive.*,user.employeename as userName
                FROM serialsarchive
                join user on user.userid = serialsarchive.userid';
        $sqlQuery = new SqlQuery($sql);
        return $this->getList($sqlQuery);
    }

    public function loadEX($id) {
        $sql = 'SELECT serialsarchive.*,user.employeename as userName
                FROM serialsarchive
                join user on user.userid = serialsarchive.userid
                where id = ' . $id;
        $sqlQuery = new SqlQuery($sql);
        return $this->getRow($sqlQuery);
    }

    public function checkifexist($devId, $userno, $syncusers, $clientname, $dateto, $synctime) {
        $sql = 'SELECT serialsarchive.id
                FROM serialsarchive
                where deviceid = "' . $devId . '" and userno = ' . $userno . '
                and syncusers = ' . $syncusers . ' and synctime = ' . $synctime . ' and clientname = "' . $clientname . '"
                and dateto = "' . $dateto . '" ';
        $sqlQuery = new SqlQuery($sql);
        return $this->getList($sqlQuery);
    }

    public function checkifexistDeviceId($devId) {
        $sql = 'SELECT serialsarchive.id
                FROM serialsarchive
                where deviceid = "' . $devId . '" ';
        $sqlQuery = new SqlQuery($sql);
        return $this->getList($sqlQuery);
    }

}

?>