|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- <?php
- // --------------------------------------------------------------------------
- // File name : test_coreseek.php
- // Description : coreseek中文全文检索系统测试程序
- // Requirement : PHP5 (http://www.php.net)
- //
- // Copyright(C), HonestQiao, 2011, All Rights Reserved.
- //
- // Author: HonestQiao (honestqiao@gmail.com)
- //
- // 最新使用文档,请查看:http://www.coreseek.cn/products/products-install/
- //
- // --------------------------------------------------------------------------
- require ( "sphinxapi.php" );
- $cl = new SphinxClient ();
- $cl->SetServer ( '127.0.0.1', 9312);
- $cl->SetConnectTimeout ( 3 );
- $cl->SetArrayResult ( true );
- $cl->SetMatchMode ( SPH_MATCH_ANY);
- $cl->SetLimits(0,20); //取从头开始的前20条数据,0,20类似SQl语句的LIMIT 0,20
- $res = $cl->Query ( '网络搜索', "*" );
- print_r($cl);
- print_r($res);
- printf("错误信息:%s
- ",$cl->GetLastError());
- printf("告警信息:%s
- ",$cl->GetLastWarning());
- printf("信息总数:%d
- ", $res['total_found']);
- printf("本页条数:%d
- ", $res['total']);
- if($res['total'])
- {
- $ids = $res['matches'];
- array_walk($ids,create_function('&$item','$item = $item["id"];'));
- $idstr = implode(',',$ids);
- printf("ID列表:%s
- ",$idstr);
- printf("查询结果:
- ");
- mysql_connect('localhost','root','123456');
- mysql_select_db('test');
- mysql_query('SET NAMES utf8');
- $query = "SELECT * FROM documents WHERE id IN ($idstr) ORDER BY id DESC";
- $res = mysql_query($query);
- while($row = mysql_fetch_assoc($res)){
- printf("id=%d title=%s
- ",$row['id'],$row['title']);
- }
- }
复制代码
|
|