source/Core/Counter.php
public function update($ident, $count)
    {
        $database = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

        /** Current counter retrieval needs to be encapsulated in transaction */
        $database->startTransaction();
        try {
            /** Block row for reading until the counter is updated */
            $query = "SELECT `oxcount` FROM `oxcounters` WHERE `oxident` = ? FOR UPDATE";
            $database->getOne($query, [$ident]);

            /** Insert or update the counter, if the value to be updated is greater, than the current value */
            $query = "INSERT INTO `oxcounters` (`oxident`, `oxcount`) VALUES (?, ?) ON DUPLICATE KEY UPDATE `oxcount` = IF(? > oxcount, ?, oxcount)";
            $result = $database->execute($query, [$ident, $count, $count, $count ]);

            $database->commitTransaction();
        } catch (Exception $exception) {
            $database->rollbackTransaction();

            throw $exception;
        }

        return $result;
    }
public function update($ident, $count)
    {
        $database = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

        /** Current counter retrieval needs to be encapsulated in transaction */
        $database->startTransaction();
        try {
            /** Block row for reading until the counter is updated */
            $query = "SELECT `oxcount` FROM `oxcounters` WHERE `oxident` = ? FOR UPDATE";
            $database->getOne($query, [$ident]);

            /** Insert or update the counter, if the value to be updated is greater, than the current value */
            $query = "INSERT INTO `oxcounters` (`oxident`, `oxcount`) VALUES (?, ?) ON DUPLICATE KEY UPDATE `oxcount` = IF(? > oxcount, ?, oxcount)";
            $result = $database->execute($query, [$ident, $count, $count, $count ]);

            $database->commitTransaction();
        } catch (Exception $exception) {
            $database->rollbackTransaction();

            throw $exception;
        }

        return $result;
    }
public function update ( $ ident , $ count ) { $ database = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; /** Current counter retrieval needs to be encapsulated in transaction */ $ database -> startTransaction ( ) ; try { /** Block row for reading until the counter is updated */ $ query = "SELECT `oxcount` FROM `oxcounters` WHERE `oxident` = ? FOR UPDATE" ; $ database -> getOne ( $ query , [ $ ident ] ) ; /** Insert or update the counter, if the value to be updated is greater, than the current value */ $ query = "INSERT INTO `oxcounters` (`oxident`, `oxcount`) VALUES (?, ?) ON DUPLICATE KEY UPDATE `oxcount` = IF(? > oxcount, ?, oxcount)" ; $ result = $ database -> execute ( $ query , [ $ ident , $ count , $ count , $ count ] ) ; $ database -> commitTransaction ( ) ; } catch ( Exception $ exception ) { $ database -> rollbackTransaction ( ) ; throw $ exception ; } return $ result ; }
Update the counter value for a given type of counter, but only when it is greater than the current value

@param string  $ident Identifies the type of counter. E.g. 'oxOrder'
@param integer $count New counter value

@throws Exception

@return int Number of affected rows
Update the counter value for a given type of counter but only when it is greater than the current value