20 $oDb->startTransaction();
22 $sQ =
"SELECT `oxcount` FROM `oxcounters` WHERE `oxident` = " . $oDb->quote($sIdent) .
" FOR UPDATE";
24 if (($iCnt = $oDb->getOne($sQ,
false,
false)) ===
false) {
25 $sQ =
"INSERT INTO `oxcounters` (`oxident`, `oxcount`) VALUES (?, '0')";
26 $oDb->execute($sQ, array($sIdent));
29 $iCnt = ((int) $iCnt) + 1;
30 $sQ =
"UPDATE `oxcounters` SET `oxcount` = ? WHERE `oxident` = ?";
31 $oDb->execute($sQ, array($iCnt, $sIdent));
33 $oDb->commitTransaction();
47 public function update($sIdent, $iCount)
50 $oDb->startTransaction();
52 $sQ =
"SELECT `oxcount` FROM `oxcounters` WHERE `oxident` = " . $oDb->quote($sIdent) .
" FOR UPDATE";
54 if (($iCnt = $oDb->getOne($sQ,
false,
false)) ===
false) {
55 $sQ =
"INSERT INTO `oxcounters` (`oxident`, `oxcount`) VALUES (?, ?)";
56 $blResult = $oDb->execute($sQ, array($sIdent, $iCount));
58 $sQ =
"UPDATE `oxcounters` SET `oxcount` = ? WHERE `oxident` = ? AND `oxcount` < ?";
59 $blResult = $oDb->execute($sQ, array($iCount, $sIdent, $iCount));
62 $oDb->commitTransaction();