search
Homephp教程php手册关于使用coreseek并为其做分页的介绍

本篇文章是对使用coreseek并为其做分页进行了详细的分析介绍,需要的朋友参考下

coreseek 做分页时找数据总量还真不好找。以为他会给一个方法(函数)什么的去获取,结果却不是。
首先需要了解:
num_matches: 当前返回的结果数,免备案空间,max_matches: 最多返回的结果数,默认为1000,用户最多只能看到1000条搜索结果。这个是在csft_mysql.conf中设置的。
total_found: 结果总数。索引中所有满足查询条件的文档总数。这个是在你查询的返回结果中的数组中有的。当然前提是你必须在query前设置:$this->sc->SetArrayResult(true);
total: 最多返回结果数,美国空间,取值取决于max_matches值和total_found值。如果total_found数超过max_matches,则total = max_matches,否则,total = total_found。这个也是在你查询的返回结果中的数组中有的。当然前提也是你必须在query前设置:$this->sc->SetArrayResult(true);
这样,了解了这几个属性之后就可以做分页了。

我们应该使用返回值中的total来做分页总数据。虽然这个不代表真实的返回值(当返回值大于max_matches,也就是1000,如真实返回2500,但是你却只能得到1000)。
代码是:

复制代码 代码如下:


$this->sc->SetServer("127.0.0.1",9312);
$this->sc->SetArrayResult(true);
$this->sc->SetLimits($start,$page);
//如果需要搜索指定全文字段的内容,可以使用扩展匹配模式:
$this->sc->SetMatchMode(SPH_MATCH_ANY);
$res = $this->sc->Query($where,"main");
$count = $res['total'];


这个¥count就是我们要的分页的总数据了。
其他的后续怎么分页是以样式和数据结构做的,不能雷同,并且分页也是基础的东西,美国服务器,所以这里就不再多说分页的详细问题了。我这里单单讨论这个总数据的取值情况。因为很多人都取count($res['matches'])的值,但是这个是分页后的返回结果,你只能得到10,或者20或者其他的值。呵呵,那就搞笑了。
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools