(1).下载3.4.1版本
http://sphinxsearch.com/downloads/current/
(2).配置数据源和索引(超精简版本)
#
# Minimal Sphinx configuration sample (clean, simple, functional)
#
source question_src
{
type = mysql
sql_host = 187.99.929.99
sql_user = legaojiufeddssdg
sql_pass = HjwmzCwALiGSDGfdf
sql_db = learojiufengfdfd
sql_port = 3306 # optional, default is 3306
sql_query = \
SELECT id,course_id,question_name \
FROM think_course_question
#sql_attr_uint = id
sql_attr_uint = course_id
}
index question
{
source = question_src
path = D:/test/indexData/
ngram_len = 1
ngram_chars = U+3000..U+2FA1F
}
indexer
{
mem_limit = 128M
}
searchd
{
listen = 9312
listen = 9306:mysql41
log = D:/test/log/searchd.log
query_log = D:/test/log/query.log
read_timeout = 5
max_children = 30
pid_file = D:/test/searchd.pid
seamless_rotate = 1
preopen_indexes = 1
unlink_old = 1
workers = threads # for RT to work
binlog_path = D:/test/data/
}(3).生成索引
indexer.exe -c ../etc/sphinx-min.conf question
(4).启动sphinx
./searchd.exe -c ../etc/sphinx-min.conf
(5).php启动查询
$cl = new SphinxClient (); $cl->SetServer($config['host'], $config['port']); $cl->SetConnectTimeout(1); $cl->SetLimits(0, $limit, 100); $res = $sphinxClient->Query($keyword, 'question');
先看看下面的代码:<?php session_start(); $_SESSION['username']='lucy'; ?>当我们请求访问上面的脚本,默认会在我们的客户端生成一个名为PHPSESSID的cookie,我这里的值是PHPSESSID=...
if($_SERVER['REQUEST_METHOD'] == 'POST') { echo('This is post '); } elseif ($_SERVER['...
使用php函数array_multisort()即可实现和SQL一样的order by排序. 例如我们需要对会员表按照主键降序排列,年龄升序排列://会员表数据 $list = []; $list[] = ['mid' =>&n...
<?php /** * @throws Exception */ function curl() { throw new \Exception('err...
在使用ftok生成ipc进程通信key尝试将第二个参数项目标识符传入字符串报错:PHP Warning: ftok(): Project identifier is invalid,查阅资料发现第二个字符串只能是1个字符串,长度为1....
众所周知MyISAM引擎不支持事务,但是我只是知道不支持事务,并未测试具体的表现是什么,测试代码如下:try { //开启事务 Db::startTrans(); &...