19 $oDb->startTransaction();
21 $sQ =
"SELECT `oxcount` FROM `oxcounters` WHERE `oxident` = " . $oDb->quote( $sIdent ) .
" FOR UPDATE";
23 if ( ( $iCnt = $oDb->getOne( $sQ,
false,
false ) ) ===
false ) {
24 $sQ =
"INSERT INTO `oxcounters` (`oxident`, `oxcount`) VALUES (?, '0')";
25 $oDb->execute( $sQ, array( $sIdent ) );
28 $iCnt = ( (int) $iCnt ) + 1;
29 $sQ =
"UPDATE `oxcounters` SET `oxcount` = ? WHERE `oxident` = ?";
30 $oDb->execute( $sQ, array( $iCnt, $sIdent ) );
32 $oDb->commitTransaction();
46 public function update( $sIdent, $iCount )
49 $oDb->startTransaction();
51 $sQ =
"SELECT `oxcount` FROM `oxcounters` WHERE `oxident` = " . $oDb->quote( $sIdent ) .
" FOR UPDATE";
53 if ( ( $iCnt = $oDb->getOne( $sQ,
false,
false ) ) ===
false ) {
54 $sQ =
"INSERT INTO `oxcounters` (`oxident`, `oxcount`) VALUES (?, ?)";
55 $blResult = $oDb->execute( $sQ, array( $sIdent, $iCount ) );
57 $sQ =
"UPDATE `oxcounters` SET `oxcount` = ? WHERE `oxident` = ? AND `oxcount` < ?";
58 $blResult = $oDb->execute( $sQ, array( $iCount, $sIdent, $iCount ) );
61 $oDb->commitTransaction();