<?php

/**
 * Class that operate on table 'projectexchmaterialreturn'. Database Mysql.
 *
 * @author: http://phpdao.com
 * @date: 2016-07-03 12:01
 */
class ProjectexchmaterialreturnMySqlExtDAO extends ProjectexchmaterialreturnMySqlDAO {

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

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

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

        $sqlQuery->setNumber($projectexchmaterialreturn->id);
        $sqlQuery->set($projectexchmaterialreturn->serilno);
        $sqlQuery->setNumber($projectexchmaterialreturn->projectid);
        $sqlQuery->setNumber($projectexchmaterialreturn->storeid);
        $sqlQuery->set($projectexchmaterialreturn->projdate);
        $sqlQuery->set($projectexchmaterialreturn->sysdate);
        $sqlQuery->set($projectexchmaterialreturn->totalnum);
        $sqlQuery->set($projectexchmaterialreturn->totalbuyprice);
        $sqlQuery->setNumber($projectexchmaterialreturn->entryid);

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

}

?>