本文整理汇总了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;
}
}
示例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;
}
示例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];
}
示例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);
示例5: SphinxClient
<?php
require "spec/fixtures/sphinxapi.php";
$cl = new SphinxClient();
$cl->Open();