public function exec($sql) { $comment = $this->getCommentWrapped(); $sql = $comment . $sql; KalturaLog::debug($sql); $sqlStart = microtime(true); try { $result = parent::exec($sql); } catch (PropelException $pex) { KalturaLog::alert($pex->getMessage()); throw new PropelException("Database error"); } $sqlTook = microtime(true) - $sqlStart; KalturaLog::debug("Sql took - " . $sqlTook . " seconds"); KalturaMonitorClient::monitorDatabaseAccess($sql, $sqlTook, $this->hostName); return $result; }
public function exec($sql) { KalturaLog::debug($sql); return parent::exec($sql); }
/** * Execute an SQL statement and return the number of affected rows. * * Overridden for query counting and logging. * * @return int */ public function exec($sql) { $debug = $this->getDebugSnapshot(); $return = parent::exec($sql); $this->log($sql, null, __METHOD__, $debug); $this->setLastExecutedQuery($sql); $this->incrementQueryCount(); return $return; }
public function exec($sql) { KalturaLog::debug($sql); $comment = $this->getCommentWrapped(); $sql = $comment . $sql; $sqlStart = microtime(true); try { $result = parent::exec($sql); } catch (PropelException $pex) { KalturaLog::alert($pex->getMessage()); throw new PropelException("Database error"); } KalturaLog::debug("Sql took - " . (microtime(true) - $sqlStart) . " seconds"); return $result; }
/** * overridden for query counting * @return int */ public function exec($sql) { $this->log('exec: ' . $sql); $this->incrementQueryCount(); return parent::exec($sql); }
public static function updatePartnerLoad($partnerId, $jobType, $jobSubType = null, PropelPDO $con = null) { $partner = PartnerPeer::retrieveByPK($partnerId); $priorityFactor = PartnerPeer::getPartnerPriorityFactorByPartner($partner); $maxQuota = $partner->getJobTypeQuota($jobType, $jobSubType); if (!$maxQuota) { $maxQuota = BatchJobLockPeer::getMaxJobsForPartner($jobType); } $dcId = kDataCenterMgr::getCurrentDcId(); // Hack to avoid the not-null constaint on job sub type if (is_null($jobSubType)) { $jobSubType = 0; } $c = new Criteria(); $c->add(self::PARTNER_ID, $partnerId); $c->add(self::JOB_TYPE, $jobType); $c->add(self::JOB_SUB_TYPE, $jobSubType); $c->add(self::DC, $dcId); $oldPartnerLoad = self::doSelectOne($c); if ($oldPartnerLoad === null) { try { // Try to insert new entry $partnerLoad = new PartnerLoad(); $partnerLoad->setPartnerId($partnerId); $partnerLoad->setJobType($jobType); $partnerLoad->setJobSubType($jobSubType); $partnerLoad->setPartnerLoad(1); $partnerLoad->setDc($dcId); $partnerLoad->setWeightedPartnerLoad($priorityFactor); $partnerLoad->setQuota($maxQuota - 1); $res = $partnerLoad->save(); if ($res == 1) { return; // if we arrived here, it means the insert was successful } } catch (Exception $e) { // probably a unique constraint - use the updae version below } } $table = PartnerLoadPeer::TABLE_NAME; $colPartnerLoad = PartnerLoadPeer::PARTNER_LOAD; $colWeightedPartnerLoad = PartnerLoadPeer::WEIGHTED_PARTNER_LOAD; $colJobType = PartnerLoadPeer::JOB_TYPE; $colJobSubType = PartnerLoadPeer::JOB_SUB_TYPE; $colPartnerId = PartnerLoadPeer::PARTNER_ID; $colDC = PartnerLoadPeer::DC; $colQuota = PartnerLoadPeer::QUOTA; $sql = "UPDATE {$table} "; $sql .= "SET {$colPartnerLoad} = ({$colPartnerLoad} + 1)"; $sql .= ", {$colWeightedPartnerLoad} = ({$colWeightedPartnerLoad} + {$priorityFactor})"; $sql .= ", {$colQuota} = ({$colQuota} - 1)"; $sql .= "WHERE {$colJobType} = {$jobType} "; $sql .= "AND {$colJobSubType} = {$jobSubType} "; $sql .= "AND {$colPartnerId} = {$partnerId} "; $sql .= "AND {$colDC} = {$dcId} "; try { $affectedRows = $con->exec($sql); } catch (Exception $e) { KalturaLog::err("Failed to update partner load with error : " . $e->getMessage()); } }