<?php

/**
 * Class that operate on table 'quickprofitday'. Database Mysql.
 *
 * @author: http://phpdao.com
 * @date: 2019-01-21 13:45
 */
class QuickprofitdayMySqlExtDAO extends QuickprofitdayMySqlDAO {

    public function insertOrUpdatePlusEX($obj) {
        //must have UNIQUE constraint on theDate
        $sql = " INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('" . $obj->theDate . "', $obj->sellVal, $obj->sellCostBuyPrice, $obj->sellCostLastBuyPrice
                    , $obj->sellCostMeanBuyPrice, $obj->sellCostLastBuyPricewithDiscount, $obj->sellCostMeanBuyPricewithDiscount, $obj->sellCostOverAllAveragePrice
                    , $obj->returnSellVal, $obj->returnSellCostBuyPrice, $obj->returnSellCostLastBuyPrice, $obj->returnSellCostMeanBuyPrice
                    , $obj->returnSellCostLastBuyPricewithDiscount, $obj->returnSellCostMeanBuyPricewithDiscount, $obj->returnSellCostOverAllAveragePrice ,$obj->sellCostLastBuyPricewithTax, $obj->sellCostMeanBuyPricewithTax, $obj->returnSellCostLastBuyPricewithTax, $obj->returnSellCostMeanBuyPricewithTax)
                ON DUPLICATE KEY UPDATE sellVal = sellVal+$obj->sellVal, sellCostBuyPrice =sellCostBuyPrice+$obj->sellCostBuyPrice
                        , sellCostLastBuyPrice = sellCostLastBuyPrice+$obj->sellCostLastBuyPrice, sellCostMeanBuyPrice = sellCostMeanBuyPrice+$obj->sellCostMeanBuyPrice
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount+$obj->sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount+$obj->sellCostMeanBuyPricewithDiscount
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice+$obj->sellCostOverAllAveragePrice
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax+$obj->sellCostLastBuyPricewithTax
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax+$obj->sellCostMeanBuyPricewithTax
                        , returnSellVal = returnSellVal+$obj->returnSellVal, returnSellCostBuyPrice = returnSellCostBuyPrice+$obj->returnSellCostBuyPrice, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice+$obj->returnSellCostLastBuyPrice
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice+$obj->returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount+$obj->returnSellCostLastBuyPricewithDiscount
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount+$obj->returnSellCostMeanBuyPricewithDiscount
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice+$obj->returnSellCostOverAllAveragePrice
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax+$obj->returnSellCostLastBuyPricewithTax
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax+$obj->returnSellCostMeanBuyPricewithTax";
        $sqlQuery = new SqlQuery($sql);
        return $this->executeUpdate($sqlQuery);
    }

    public function insertOrUpdateMinusEX($obj) {
        //must have UNIQUE constraint on theDate
        $sql = " INSERT INTO quickprofitday (theDate, sellVal, sellCostBuyPrice, sellCostLastBuyPrice, sellCostMeanBuyPrice, sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount, sellCostOverAllAveragePrice, returnSellVal, returnSellCostBuyPrice, returnSellCostLastBuyPrice, returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount, returnSellCostMeanBuyPricewithDiscount,returnSellCostOverAllAveragePrice,sellCostLastBuyPricewithTax,sellCostMeanBuyPricewithTax,returnSellCostLastBuyPricewithTax,returnSellCostMeanBuyPricewithTax)
                    VALUES ('" . $obj->theDate . "', $obj->sellVal, $obj->sellCostBuyPrice, $obj->sellCostLastBuyPrice
                    , $obj->sellCostMeanBuyPrice, $obj->sellCostLastBuyPricewithDiscount, $obj->sellCostMeanBuyPricewithDiscount, $obj->sellCostOverAllAveragePrice
                    , $obj->returnSellVal, $obj->returnSellCostBuyPrice, $obj->returnSellCostLastBuyPrice, $obj->returnSellCostMeanBuyPrice
                    , $obj->returnSellCostLastBuyPricewithDiscount, $obj->returnSellCostMeanBuyPricewithDiscount, $obj->returnSellCostOverAllAveragePrice ,$obj->sellCostLastBuyPricewithTax, $obj->sellCostMeanBuyPricewithTax, $obj->returnSellCostLastBuyPricewithTax, $obj->returnSellCostMeanBuyPricewithTax)
                ON DUPLICATE KEY UPDATE sellVal = sellVal-$obj->sellVal, sellCostBuyPrice =sellCostBuyPrice-$obj->sellCostBuyPrice
                        , sellCostLastBuyPrice = sellCostLastBuyPrice-$obj->sellCostLastBuyPrice, sellCostMeanBuyPrice = sellCostMeanBuyPrice-$obj->sellCostMeanBuyPrice
                        , sellCostLastBuyPricewithDiscount = sellCostLastBuyPricewithDiscount-$obj->sellCostLastBuyPricewithDiscount, sellCostMeanBuyPricewithDiscount = sellCostMeanBuyPricewithDiscount-$obj->sellCostMeanBuyPricewithDiscount
                            , sellCostOverAllAveragePrice = sellCostOverAllAveragePrice-$obj->sellCostOverAllAveragePrice
                            , sellCostLastBuyPricewithTax = sellCostLastBuyPricewithTax-$obj->sellCostLastBuyPricewithTax
                            , sellCostMeanBuyPricewithTax = sellCostMeanBuyPricewithTax-$obj->sellCostMeanBuyPricewithTax
                        , returnSellVal = returnSellVal-$obj->returnSellVal, returnSellCostBuyPrice = returnSellCostBuyPrice-$obj->returnSellCostBuyPrice, returnSellCostLastBuyPrice = returnSellCostLastBuyPrice-$obj->returnSellCostLastBuyPrice
                        , returnSellCostMeanBuyPrice = returnSellCostMeanBuyPrice-$obj->returnSellCostMeanBuyPrice, returnSellCostLastBuyPricewithDiscount = returnSellCostLastBuyPricewithDiscount-$obj->returnSellCostLastBuyPricewithDiscount
                        , returnSellCostMeanBuyPricewithDiscount = returnSellCostMeanBuyPricewithDiscount-$obj->returnSellCostMeanBuyPricewithDiscount
                            , returnSellCostOverAllAveragePrice = returnSellCostOverAllAveragePrice-$obj->returnSellCostOverAllAveragePrice
                            , returnSellCostLastBuyPricewithTax = returnSellCostLastBuyPricewithTax-$obj->returnSellCostLastBuyPricewithTax
                            , returnSellCostMeanBuyPricewithTax = returnSellCostMeanBuyPricewithTax-$obj->returnSellCostMeanBuyPricewithTax";
        $sqlQuery = new SqlQuery($sql);
        return $this->executeUpdate($sqlQuery);
    }

    public function queryAllEX($queryString) {
        $sql = "SELECT * FROM quickprofitday where 1 $queryString";
        $sqlQuery = new SqlQuery($sql);
        return $this->getList($sqlQuery);
    }

    public function truncate() {
        $sql = "TRUNCATE quickprofitday";
        $sqlQuery = new SqlQuery($sql);
        return $this->getList($sqlQuery);
    }

}

?>