New version of kohana sphinxql from working project
This commit is contained in:
parent
bba58121a6
commit
a2739bc749
|
@ -1,9 +1,18 @@
|
|||
SphinxQL for Kohana 3.2
|
||||
SphinxQL for Kohana
|
||||
===================
|
||||
|
||||
Overview
|
||||
--------
|
||||
This is sphinx plugin for kohana 3.2
|
||||
|
||||
I wrote this because the other Kohana Sphinx plugin on github was reliant on
|
||||
the pure PHP sphinx API and was discontinued. This plugin, as suggested by its
|
||||
name, uses the SphinxQL interface. This means there's less dependancies as it
|
||||
uses the built-in MySQL interface from PHP. _NOTE_: to use this, MySQL server
|
||||
does _NOT_ need to be installed on the server. Only the MySQL client library for
|
||||
PHP is required. As the MySQL interface in PHP is built as an extension, it's
|
||||
faster than the regular Sphinx API as well, you can check the benchmarks out
|
||||
here: http://sphinxsearch.com/blog/2010/04/25/sphinxapi-vs-sphinxql-benchmark/
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
|
|
|
@ -73,10 +73,22 @@ class Kohana_SphinxQL_Client {
|
|||
*/
|
||||
public function query($query) {
|
||||
$this->_result = false;
|
||||
if (is_string($query) && $this->connect()) { $this->_result = mysql_query($query, $this->_handle); }
|
||||
if (is_string($query) && $this->connect()) {
|
||||
@$this->_result = mysql_query($query, $this->_handle);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function total_find() {
|
||||
$result = mysql_query("SHOW META");
|
||||
if($result) {
|
||||
$result = mysql_fetch_assoc($result);
|
||||
return intval($result['Value']);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch one row of the result set
|
||||
*
|
||||
|
@ -101,4 +113,4 @@ class Kohana_SphinxQL_Client {
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -75,11 +75,13 @@ class Kohana_SphinxQL_Core {
|
|||
if (!is_a($query, 'SphinxQL_Query') && !is_string($query)) { return false; }
|
||||
while (($names = array_keys(self::$_handles)) && count($names) && ($name = $names[intval(rand(0, count($names)-1))])) {
|
||||
$client = self::$_handles[$name];
|
||||
$return = $client->query((string)$query)->fetch_all();
|
||||
$result = $client->query((string)$query);
|
||||
$return['data'] = $client->query((string)$query)->fetch_all();
|
||||
$return['total'] = $client->total_find();
|
||||
if (is_array($return)) { return $return; } else { unset(self::$_handles[$name]); }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -26,10 +26,9 @@ return array(
|
|||
//'sphinx_second' => '123.45.67.89:8765',
|
||||
|
||||
// ...or!
|
||||
//'my_only_server' => '127.0.0.1:2222',
|
||||
'my_only_server' => '127.0.0.1:9312',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue