PHP调用Sphinx API公共类

PHP调用Sphinx类API

最近TP5的项目用到了sphinx,sphinx如何安装配置百度都有,但是如何用php调用sphinx第三方,网上能直接使用的并不多,所以做了一个简单的可以直接使用的调用sphinx API的类,直接上代码

<?php
namespace Sphinx;

/**
 * sphinx公共查询类
 * @author      五个A的猪
 * @version     1.0 版本号
 */

class Sphinx
{
   
    /**
     *sphinx 查询
     *
     * @access public
     * @param string $ip 服务器ip
     * @param string $name 查询sphinx名称
     * @param array $where  查询条件:数组传参,单字段多数据传$where['test']=array(1,2,3);
     * @param array $where['between'] 查询在字段值在某两个值之间参数,$where['between']['test'] = array(1,10);
     * @param int $page 分页
     * @param int $return_type aid返回类型:默认数组,1为字符串
     * @param string $wherelogic 查询条件逻辑符号 & 和 |
     * @param string $whereconn 查询条件连接符号  空格 和 =
     * @param string $page_count 每页显示的数量
     * @return array 返回类型
     */
    public function sphinx_search($ip='',$name='',$where=array(),$page='',$return_type=0,$wherelogic="&",$whereconn=' ',$page_count=50){
   
        $cl = new \sphinx\SphinxClient();
        $cl->SetServer ($ip, 9312);
        $cl->SetMatchMode (SPH_MATCH_EXTENDED2);//默认模式
        $cl->SetSortMode (SPH_SORT_EXTENDED,"@id DESC");
        if
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值