/**
  * @param string $sql
  * @param IIndexable $object
  * @return bool
  */
 public function execSphinx($sql, IIndexable $object)
 {
     KalturaLog::debug($sql);
     $sphinxConnection = null;
     $sphinxConnectionId = null;
     if (kConf::hasParam('exec_sphinx') && kConf::get('exec_sphinx')) {
         $sphinxConnection = DbManager::getSphinxConnection(false);
         $sphinxServer = SphinxLogServerPeer::retrieveByLocalServer($sphinxConnection->getHostName());
         if ($sphinxServer) {
             $sphinxConnectionId = $sphinxServer->getId();
         }
     }
     $sphinxLog = new SphinxLog();
     $sphinxLog->setExecutedServerId($sphinxConnectionId);
     $sphinxLog->setObjectId($object->getId());
     $sphinxLog->setObjectType(get_class($object));
     $sphinxLog->setEntryId($object->getEntryId());
     $sphinxLog->setPartnerId($object->getPartnerId());
     $sphinxLog->setSql($sql);
     $sphinxLog->save(myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_SPHINX_LOG));
     if (!$sphinxConnection) {
         return true;
     }
     $sphinxConnection = DbManager::getSphinxConnection(false);
     $ret = $sphinxConnection->exec($sql);
     if ($ret) {
         return true;
     }
     $arr = $sphinxConnection->errorInfo();
     KalturaLog::err($arr[2]);
     return false;
 }
Пример #2
0
 private function retrieveSphinxConnectionId()
 {
     $sphinxConnectionId = null;
     if (kConf::hasParam('exec_sphinx') && kConf::get('exec_sphinx')) {
         $sphinxConnection = DbManager::getSphinxConnection(false);
         $sphinxServerCacheStore = kCacheManager::getSingleLayerCache(kCacheManager::CACHE_TYPE_SPHINX_EXECUTED_SERVER);
         if ($sphinxServerCacheStore) {
             $sphinxConnectionId = $sphinxServerCacheStore->get(self::CACHE_PREFIX . $sphinxConnection->getHostName());
             if ($sphinxConnectionId) {
                 return $sphinxConnectionId;
             }
         }
         $sphinxServer = SphinxLogServerPeer::retrieveByLocalServer($sphinxConnection->getHostName());
         if ($sphinxServer) {
             $sphinxConnectionId = $sphinxServer->getId();
             if ($sphinxServerCacheStore) {
                 $sphinxServerCacheStore->set(self::CACHE_PREFIX . $sphinxConnection->getHostName(), $sphinxConnectionId);
             }
         }
     }
     return $sphinxConnectionId;
 }