Sphinx 读取ID列表演示PHP代码
<?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']);
}
}
看来PHP和ASPX相差很大啊,我就看懂一点点。。。 呵呵,看下应该就会明白许多了吧 鳳凰の馨蘭寺 发表于 2011-8-1 20:23 static/image/common/back.gif
看来PHP和ASPX相差很大啊,我就看懂一点点。。。
呵呵,看下应该就会明白许多了吧 :( ding呀 支持
static/image/common/sigline.gif
夜晨影院 影视界 正味网
页:
[1]