<?php

/**
 * Class that operate on table 'onlinetempproduct'. Database Mysql.
 *
 * @author: http://phpdao.com
 * @date: 2019-11-16 10:42
 */
class OnlinetempproductMySqlExtDAO extends OnlinetempproductMySqlDAO {

    public function insertOrUpdateOnDuplicate($obj) {
        //must have UNIQUE constraint on the the column we need
        //ALTER TABLE onlinetempstoredetail ADD CONSTRAINT uniquecombination UNIQUE(`storeid`,`productid`,`sizeid`,`colorid`)
        $sql = "INSERT INTO onlinetempproduct (productid, edited, sysdate, userid)
                VALUES ($obj->productid, $obj->edited,'" . $obj->sysdate . "',$obj->userid)
                ON DUPLICATE KEY UPDATE productid = $obj->productid, edited = $obj->edited, sysdate = '" . $obj->sysdate . "', userid = $obj->userid";
        $sqlQuery = new SqlQuery($sql);
        return $this->executeUpdate($sqlQuery);
    }

    public function TRUNCATE() {
        $sql = "TRUNCATE onlinetempproduct";
        $sqlQuery = new SqlQuery($sql);
        return $this->executeUpdate($sqlQuery);
    }

}

?>