当前位置: 首页>>代码示例>>PHP>>正文


PHP SphinxClient::Open方法代码示例

本文整理汇总了PHP中SphinxClient::Open方法的典型用法代码示例。如果您正苦于以下问题:PHP SphinxClient::Open方法的具体用法?PHP SphinxClient::Open怎么用?PHP SphinxClient::Open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SphinxClient的用法示例。


在下文中一共展示了SphinxClient::Open方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: closeConnection

 public function closeConnection()
 {
     if (!$this->isConnected) {
         throw new ESphinxException("Sphinx client is already closed");
     } else {
         $this->sphinxClient->Open();
         $this->isConnected = false;
     }
 }
开发者ID:jerrylsxu,项目名称:yii-sphinx,代码行数:9,代码来源:ESphinxConnection.php

示例2: openConnection

 /**
  * Open Sphinx persistent connection.
  *
  * @throws ESphinxException if client is already connected.
  * @throws ESphinxException if client has connection error.
  * @link http://sphinxsearch.com/docs/current.html#api-func-open
  */
 public function openConnection()
 {
     if ($this->isConnected) {
         throw new ESphinxException("Sphinx client is already opened");
     }
     $this->sphinxClient->Open();
     if ($this->sphinxClient->IsConnectError()) {
         throw new ESphinxException("Sphinx exception: " . $this->sphinxClient->GetLastError());
     }
     $this->isConnected = true;
 }
开发者ID:sergebezborodov,项目名称:sphinx-yii,代码行数:18,代码来源:ESphinxApiConnection.php

示例3: getInstance

 public static function getInstance($sphinxconf, $type = 'media')
 {
     $time = microtime(true);
     $rand = intval(substr($time, 11, 4));
     $num = count($sphinxconf);
     $index = $rand % $num;
     $ret = false;
     if (null == self::$_sphinxpool[$type]) {
         $try_count = 0;
         while ($try_count < 3 && $ret != true) {
             $client = new SphinxClient();
             $index = $index % $num;
             try {
                 $client->setServer($sphinxconf[$index]['host'], $sphinxconf[$index]['port']);
                 self::$_index[$type] = $sphinxconf[$index]['indexer'];
                 $ret = $client->Open();
                 if ($ret == true) {
                     self::$_conf_num[$type] = $index;
                     break;
                 }
                 Systemlog::fatal("sphinx connect fail time:" . $client->_host . " " . $client->_port);
                 $try_count++;
                 $index++;
             } catch (Exception $e) {
                 $index++;
                 $try_count++;
             }
         }
         self::$_sphinxpool[$type] = $client;
     }
     return self::$_sphinxpool[$type];
 }
开发者ID:glianyi,项目名称:MyPHP,代码行数:32,代码来源:sphinxha.php

示例4: getAllKey

<?php

require 'sphinxapi.php';
$dbLocal = new PDO('mysql:host=localhost;dbname=words', 'root', 'root');
$dbData = new PDO('mysql:host=localhost;dbname=words', 'root', 'root');
$sql = 'set names utf8';
$dbLocal->exec($sql);
$dbData->exec($sql);
$sphinx = new SphinxClient();
@$sphinx->SetServer('127.0.0.1', '9312');
$sphinx->Open();
$spamArray = array();
$healthArray = array();
function getAllKey($sql, $dbData, $sphinx)
{
    $allKey = array();
    $result = $dbData->query($sql);
    while ($row = $result->fetch()) {
        //$pattern = '/[a-zA-Z0-9\x{4e00}-\x{9fa5}]+/u';
        //$pattern = '/[\x{4e00}-\x{9fa5}]+/u';
        //preg_match_all($pattern, $row['content'], $content);
        //$content = join('', $content[0]);
        $key = $sphinx->buildKeywords($row['content'], 'mysql', false);
        $num = count($key);
        if ($num) {
            for ($i = 0; $i < $num; $i++) {
                $key[$i] = $key[$i]['tokenized'];
            }
        }
        $key = array_unique($key);
        $allKey = array_merge($key, $allKey);
开发者ID:sdgdsffdsfff,项目名称:Bayes,代码行数:31,代码来源:initData.php

示例5: SphinxClient

<?php

require "spec/fixtures/sphinxapi.php";
$cl = new SphinxClient();
$cl->Open();
开发者ID:alpbs,项目名称:sphinx,代码行数:5,代码来源:open.php


注:本文中的SphinxClient::Open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。