'ets_rv_product_comment_order', 'primary' => '', 'multilang' => false, 'fields' => array( 'id_ets_rv_product_comment' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'id_order' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'id_product' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 500), ), ); public static function getOldestOrder($id_product) { if (!$id_product || !Validate::isUnsignedInt($id_product)) { return false; } $dq = new DbQuery(); $dq ->select('o.id_order') ->from('orders', 'o') ->leftJoin('order_detail', 'od', 'od.id_order = o.id_order') ->leftJoin('ets_rv_product_comment_order', 'pco', 'pco.id_order = o.id_order AND pco.id_product = od.product_id') ->where('od.product_id = ' . (int)$id_product) ->where('pco.id_product is NULL OR pco.id_product <= 0'); return (int)Db::getInstance()->getValue($dq); } public static function getReviewed($id_order, $id_product) { if (!$id_product || !Validate::isUnsignedInt($id_product) || !$id_order || !Validate::isUnsignedInt($id_order) ) { return false; } $dq = new DbQuery(); $dq ->select('id_ets_rv_product_comment') ->from('ets_rv_product_comment_order', 'pco') ->where('pco.id_product = ' . (int)$id_product) ->where('pco.id_order = ' . (int)$id_order); return (int)Db::getInstance()->getValue($dq); } public static function saveData($multi_data = array()) { if (!is_array($multi_data) || !count($multi_data)) { return false; } return Db::getInstance()->insert(self::$definition['table'], $multi_data, true, true, Db::INSERT_IGNORE); } public static function deleteReviewed($product_comment_id) { if (!$product_comment_id || !Validate::isUnsignedInt($product_comment_id)) { return false; } return Db::getInstance()->delete('ets_rv_product_comment_order', 'id_ets_rv_product_comment=' . (int)$product_comment_id); } }