这个代码,用thinkphp怎么写,
时间:2011-06-16
来源:互联网
这个是PHP调取 sphinx API 搜索数据的程序,用thinkphp怎么写呢?
复制代码
- <?php
- include 'sphinxapi.php';
- $sp=new SphinxClient();
- $sp->setServer('localhost',9312);
- $res=$sp->query('中国','mysql');
- $ids=join(',',array_keys($res['matches']));
- $sql="select * from documents where id in($ids)";
- $conn=new mysqli('localhost','root','liwenkaihaha','test');
- $conn->set_charset('utf8');
- $result=$conn->query($sql);
- while($rows=$result->fetch_assoc()){
- echo '<li>标题为'.$rows['title'].'</li>';
- echo '<li>搜索出来的内容为'.$rows['content'].'</li>';
- }
-
-
- ?>
作者: feigou 发布时间: 2011-06-16
改名为SphinxClient.class.php放到Lib\Util\目录下
include 'sphinxapi.php';
改为:
import('@.Util.SphinxClient');
下面的代码还是一样的。
include 'sphinxapi.php';
改为:
import('@.Util.SphinxClient');
下面的代码还是一样的。
作者: deeka 发布时间: 2011-06-16
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28