<?php

/**
 * Class that operate on table 'productionrate'. Database Mysql.
 *
 * @author: http://phpdao.com
 * @date: 2014-04-01 11:09
 */
class ProductionrateMySqlExtDAO extends ProductionrateMySqlDAO {

    public function queryOneRateByfinalName($id) {
        $sql = 'SELECT * FROM productionrate WHERE finalName = ?';
        $sqlQuery = new SqlQuery($sql);
        $sqlQuery->setNumber($id);
        return $this->getRow($sqlQuery);
    }

    public function queryAllRateByfinalNameSC($id) {
        $sql = 'SELECT productionrate.*, product.productName,productcat.productCatName
                ,productSellAllPrice,productSellHalfPrice,productSellUnitPrice
                ,size.name as sizeName,color.name as colorName
                FROM productionrate
                join product on productionrate.finalName = product.productId
		JOIN productcat
                        ON product.productCatId = productcat.productCatId
                left join sizecolor as size on size.id=productionrate.sizeid
                left join sizecolor as color on color.id=productionrate.colorid
                WHERE finalName = ?';
        $sqlQuery = new SqlQuery($sql);
        $sqlQuery->setNumber($id);
        return $this->getList($sqlQuery);
    }

    public function deleteByfinalName($id) {
        $sql = 'DELETE FROM productionrate WHERE finalName = ?';
        $sqlQuery = new SqlQuery($sql);
        $sqlQuery->setNumber($id);
        return $this->executeUpdate($sqlQuery);
    }

    public function queryAllProductEquation($id) {
        $sql = 'SELECT productionrate.* , product.productName, product.productId FROM productionrate,product where productionrate.finalName = product.productId and conditions=0';
        $sqlQuery = new SqlQuery($sql);
        return $this->getList($sqlQuery);
    }

}

?>