1
phzzy 2012-12-05 11:05:52 +08:00
$page = isset($_GET['p']) ? intval($_GET['p']) : 1;
if($page <= 0) $page = 1; $pagesize = 20; $s = new SphinxClient (); $s->SetServer('localhost' , 9312); $s->SetLimits(($page - 1) * $pagesize , $pagesize , 3000); $s->SetMaxQueryTime(3000); $s->SetSortMode(SPH_SORT_ATTR_DESC , 'id_attr'); $result = $s->Query($keyword , 'lixiansou'); if(empty($result) || $result['total_found'] == 0) { $count = 0; $ids = array(); } else { $count = $result['total_found']; $ids = array_keys($result['matches']); } php 对应的一段 sphinx api 代码 返回结果中有 total_found 用来分页 |
2
wyx OP 谢谢~我之前没注意到total_found
|