-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathsphinx.cls.php
executable file
·63 lines (53 loc) · 1.34 KB
/
sphinx.cls.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/*
* This file is part of the phpems/phpems.
*
* (c) oiuv <[email protected]>
*
* 项目维护:oiuv(QQ:7300637) | 定制服务:火眼(QQ:278768688)
*
* This source file is subject to the MIT license that is bundled.
*/
class sphinx
{
public $G;
public $sphinxapi;
public function __construct(&$G)
{
$this->G = $G;
$this->connectSphinx(SPHIP, SPHPORT, SPHUNAME, SPHUPASS);
}
private function connectSphinx($ip, $port, $uname, $upass)
{
if (!$this->sphinxapi) {
include 'lib/include/sphinxapi.php';
$this->sphinxapi = new SphinxClient();
$this->sphinxapi->SetServer($ip, $port);
$this->setMatchMode();
}
}
public function setLimits($start, $number = 20)
{
$this->sphinxapi->SetLimits($start, $number);
}
public function setMode($mode, $value)
{
$this->sphinxapi->$mode($value);
}
public function setFilter($mode)
{
$this->sphinxapi->SetFilter($mode);
}
public function setSortMode($mode)
{
$this->sphinxapi->SetSortMode($mode);
}
public function setMatchMode($mode = 'SPH_MATCH_ANY')
{
$this->sphinxapi->SetMatchMode($mode);
}
public function query($keyword, $type = '*')
{
return $this->sphinxapi->Query($keyword, $type);
}
}