Пример #1
0
 public function multiInit($options)
 {
     //$cnf = $this->config->item('p_sphinx');
     if ($options) {
         foreach ($options as $key => $val) {
             $this->lOptions[$key] = $val;
         }
     }
     if (!isset($this->lOptions['index'])) {
         $this->sError = 'Index not defined';
         return FALSE;
     }
     $indexToSearch = trim($this->lOptions['index']);
     /*
     if(!isset($cnf['indexes'][$indexToSearch])){
         $this->sError = 'Index '.$indexToSearch.' not found in configuration';
         return FALSE;
     }
     */
     $serverToConnect = $this->sphinxServers[0];
     //die($serverToConnect);
     if (self::$oSphinx == NULL) {
         // "opening ... ";
         self::$oSphinx = new SphinxClient();
     } else {
         if ($serverToConnect != self::$lastUsedServer) {
             self::$oSphinx->Close();
             //echo "Setting server:".self::$lastUsedServer."<br />";
         }
     }
     self::$lastUsedServer = $serverToConnect;
     //echo "Using server:".self::$lastUsedServer."<br />";
     $this->m_aDegugArry['server'] = $serverToConnect;
     $this->m_aDegugArry['port'] = $this->cnf->port;
     self::$oSphinx->SetServer($serverToConnect, (int) $this->cnf->port);
     self::$oSphinx->ResetFilters();
     self::$oSphinx->ResetGroupBy();
     if (isset($this->lOptions['connectTimeout'])) {
         self::$oSphinx->SetConnectTimeout((int) $this->lOptions['connectTimeout']);
     } else {
         self::$oSphinx->SetConnectTimeout(1);
     }
 }