<?php

/**
 * Class that operate on table 'expenseexchange'. Database Mysql.
 *
 * @author: http://phpdao.com
 * @date: 2016-07-04 11:25
 */
class ExpenseexchangeMySqlExtDAO extends ExpenseexchangeMySqlDAO {

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

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

    /**
     * Insert record to table
     *
     * @param ExpenseexchangeMySql expenseexchange
     */
    public function insertWithID($expenseexchange) {
        $sql = 'INSERT INTO expenseexchange (id,serialno, projectid, expensefrom, expenseid, expenseid2, thevalue, costcenterid, expensedate, expensetype, userid, del, sysdate, entryid, expenseexcomment,images) VALUES (?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
        $sqlQuery = new SqlQuery($sql);

        $sqlQuery->setNumber($expenseexchange->id);
        $sqlQuery->set($expenseexchange->serialno);
        $sqlQuery->setNumber($expenseexchange->projectid);
        $sqlQuery->setNumber($expenseexchange->expensefrom);
        $sqlQuery->setNumber($expenseexchange->expenseid);
        $sqlQuery->setNumber($expenseexchange->expenseid2);
        $sqlQuery->setNumber($expenseexchange->thevalue);
        $sqlQuery->setNumber($expenseexchange->costcenterid);
        $sqlQuery->set($expenseexchange->expensedate);
        $sqlQuery->setNumber($expenseexchange->expensetype);
        $sqlQuery->setNumber($expenseexchange->userid);
        $sqlQuery->setNumber($expenseexchange->del);
        $sqlQuery->set($expenseexchange->sysdate);
        $sqlQuery->setNumber($expenseexchange->entryid);
        $sqlQuery->set($expenseexchange->expenseexcomment);
        $sqlQuery->set($expenseexchange->images);

        $id = $this->executeInsert($sqlQuery);
        $expenseexchange->id = $id;

        return $id;
    }

}

?>