Beispiel #1
0
 protected static function initGlobalMemcache()
 {
     if (self::$s_memcacheInited) {
         return;
     }
     self::$s_memcacheInited = true;
     self::$s_memcacheKeys = kCacheManager::getSingleLayerCache(kCacheManager::CACHE_TYPE_QUERY_CACHE_KEYS);
     if (self::$s_memcacheKeys === null) {
         // no reason to init the queries server, the query cache won't be used anyway
         return;
     }
     self::$s_memcacheQueries = kCacheManager::getSingleLayerCache(kCacheManager::CACHE_TYPE_QUERY_CACHE_QUERIES);
 }
Beispiel #2
0
 public function execute($input_parameters = null)
 {
     if (!kQueryCache::isCurrentQueryHandled()) {
         kApiCache::disableConditionalCache();
     }
     $search = array();
     $replace = array();
     if (is_null($input_parameters)) {
         $search = array_reverse(array_keys($this->values));
         $replace = array_reverse($this->values);
     } else {
         $i = 1;
         foreach ($input_parameters as $value) {
             $search[] = ':p' . $i++;
             if (is_null($value)) {
                 $replace[] = "NULL";
             } else {
                 $replace[] = "'{$value}'";
             }
         }
         $search = array_reverse($search);
         $replace = array_reverse($replace);
     }
     $sql = str_replace($search, $replace, $this->queryString);
     KalturaLog::debug($sql);
     $sqlStart = microtime(true);
     if (self::$dryRun && !preg_match('/^(\\/\\*.+\\*\\/ )?SELECT/i', $sql)) {
         KalturaLog::debug("Sql dry run - " . (microtime(true) - $sqlStart) . " seconds");
     } else {
         try {
             parent::execute($input_parameters);
         } 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);
     }
 }
 /**
  * Method to do selects.
  *
  * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
  * @param      PropelPDO $con
  * @return     array Array of selected Objects
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelect(Criteria $criteria, PropelPDO $con = null)
 {
     $criteriaForSelect = MetadataProfilePeer::prepareCriteriaForSelect($criteria);
     $queryDB = kQueryCache::QUERY_DB_UNDEFINED;
     $cacheKey = null;
     $cachedResult = kQueryCache::getCachedQueryResults($criteriaForSelect, kQueryCache::QUERY_TYPE_SELECT, 'MetadataProfilePeer', $cacheKey, $queryDB);
     if ($cachedResult !== null) {
         $cacheKey = null;
         MetadataProfilePeer::filterSelectResults($cachedResult, $criteriaForSelect);
         MetadataProfilePeer::updateInstancePool($cachedResult);
         return $cachedResult;
     }
     $con = MetadataProfilePeer::alternativeCon($con, $queryDB);
     $queryResult = MetadataProfilePeer::populateObjects(BasePeer::doSelect($criteriaForSelect, $con));
     if ($criteriaForSelect instanceof KalturaCriteria) {
         $criteriaForSelect->applyResultsSort($queryResult);
     }
     if ($cacheKey !== null) {
         kQueryCache::cacheQueryResults($cacheKey, $queryResult);
         $cacheKey = null;
     }
     MetadataProfilePeer::filterSelectResults($queryResult, $criteria);
     MetadataProfilePeer::addInstancesToPool($queryResult);
     return $queryResult;
 }
 /**
  * Code to be run after updating the object in database
  * @param PropelPDO $con
  */
 public function postUpdate(PropelPDO $con = null)
 {
     if ($this->alreadyInSave) {
         return;
     }
     kQueryCache::invalidateQueryCache($this);
     parent::postUpdate($con);
 }
 /**
  * Code to be run after updating the object in database
  * @param PropelPDO $con
  */
 public function postUpdate(PropelPDO $con = null)
 {
     if ($this->alreadyInSave) {
         return;
     }
     if ($this->isModified()) {
         kQueryCache::invalidateQueryCache($this);
         kEventsManager::raiseEvent(new kObjectChangedEvent($this, $this->tempModifiedColumns));
     }
     $this->tempModifiedColumns = array();
     parent::postUpdate($con);
 }
Beispiel #6
0
 /**
  * Code to be run after updating the object in database
  * @param PropelPDO $con
  */
 public function postUpdate(PropelPDO $con = null)
 {
     if ($this->alreadyInSave) {
         return;
     }
     if ($this->isModified()) {
         kQueryCache::invalidateQueryCache($this);
         $modifiedColumns = $this->tempModifiedColumns;
         $modifiedColumns[kObjectChangedEvent::CUSTOM_DATA_OLD_VALUES] = $this->oldCustomDataValues;
         kEventsManager::raiseEvent(new kObjectChangedEvent($this, $modifiedColumns));
     }
     $this->tempModifiedColumns = array();
     parent::postUpdate($con);
 }