<?php

/**
 * Class that operate on table 'projectexchmaterial'. Database Mysql.
 *
 * @author: http://phpdao.com
 * @date: 2016-06-28 14:17
 */
class ProjectexchmaterialMySqlExtDAO extends ProjectexchmaterialMySqlDAO {

    public function queryAllbyserialno($serialno) {
        $sql = 'SELECT * FROM projectexchmaterial where serilno =' . $serialno . '';
        $sqlQuery = new SqlQuery($sql);
        return $this->getList($sqlQuery);
    }

    public function queryAllEX($queryString) {
        $sql = 'SELECT projectexchmaterial.*,project.name as projectid, employeename FROM projectexchmaterial join project on project.id = projectexchmaterial.projectid
        LEFT JOIN user ON projectexchmaterial.userid = user.userid   ' . $queryString . ' order by id desc';
        $sqlQuery = new SqlQuery($sql);
        return $this->getList($sqlQuery);
    }

    /**
     * Insert record to table
     *
     * @param ProjectexchmaterialMySql projectexchmaterial
     */
    public function insertWithID($projectexchmaterial) {
        $sql = 'INSERT INTO projectexchmaterial (id,serilno, projectid, storeid, projdate, sysdate, totalnum,totalbuyprice,entryid,supervision_type,supervision_amount,supplierid) VALUES (?,?,?,?, ?, ?, ?, ?, ?, ?, ?, ?)';
        $sqlQuery = new SqlQuery($sql);

        $sqlQuery->setNumber($projectexchmaterial->id);
        $sqlQuery->set($projectexchmaterial->serilno);
        $sqlQuery->setNumber($projectexchmaterial->projectid);
        $sqlQuery->setNumber($projectexchmaterial->storeid);
        $sqlQuery->set($projectexchmaterial->projdate);
        $sqlQuery->set($projectexchmaterial->sysdate);
        $sqlQuery->set($projectexchmaterial->totalnum);
        $sqlQuery->set($projectexchmaterial->totalbuyprice);
        $sqlQuery->setNumber($projectexchmaterial->entryid);
        $sqlQuery->set($projectexchmaterial->supervision_type);
        $sqlQuery->set($projectexchmaterial->supervision_amount);
        $sqlQuery->setNumber($projectexchmaterial->supplierid);

        $id = $this->executeInsert($sqlQuery);
        $projectexchmaterial->id = $id;
        return $id;
    }

}

?>