source/Core/Counter.php
public function getNext($ident)
    {
        $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";
            $currentCounter = (int) $database->getOne($query, [$ident]);
            $nextCounter = $currentCounter + 1;

            /** Insert or increment the the counter */
            $query = "INSERT INTO `oxcounters` (`oxident`, `oxcount`) VALUES (?, 1) ON DUPLICATE KEY UPDATE `oxcount` = `oxcount` + 1";
            $database->execute($query, [$ident]);

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

            throw $exception;
        }

        return $nextCounter;
    }
public function getNext($ident)
    {
        $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";
            $currentCounter = (int) $database->getOne($query, [$ident]);
            $nextCounter = $currentCounter + 1;

            /** Insert or increment the the counter */
            $query = "INSERT INTO `oxcounters` (`oxident`, `oxcount`) VALUES (?, 1) ON DUPLICATE KEY UPDATE `oxcount` = `oxcount` + 1";
            $database->execute($query, [$ident]);

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

            throw $exception;
        }

        return $nextCounter;
    }
public function getNext ( $ ident ) { $ 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" ; $ currentCounter = ( int ) $ database -> getOne ( $ query , [ $ ident ] ) ; $ nextCounter = $ currentCounter + 1 ; /** Insert or increment the the counter */ $ query = "INSERT INTO `oxcounters` (`oxident`, `oxcount`) VALUES (?, 1) ON DUPLICATE KEY UPDATE `oxcount` = `oxcount` + 1" ; $ database -> execute ( $ query , [ $ ident ] ) ; $ database -> commitTransaction ( ) ; } catch ( Exception $ exception ) { $ database -> rollbackTransaction ( ) ; throw $ exception ; } return $ nextCounter ; }
Return the next counter value for a given type of counter

@param string $ident Identifies the type of counter. E.g. 'oxOrder'

@throws Exception

@return int Next counter value
Return the next counter value for a given type of counter