当前位置: 首页>>代码示例>>PHP>>正文


PHP SearchResult::sphinxResult2searchResult方法代码示例

本文整理汇总了PHP中SearchResult::sphinxResult2searchResult方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchResult::sphinxResult2searchResult方法的具体用法?PHP SearchResult::sphinxResult2searchResult怎么用?PHP SearchResult::sphinxResult2searchResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SearchResult的用法示例。


在下文中一共展示了SearchResult::sphinxResult2searchResult方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: searchBySphinx

	private function searchBySphinx($request, $response, $kw, $p)
	{/*{{{*/
        $doctorSearchd = SphinxSearchdBase::createSearchdByType('Doctor');
        $utf8Kw = mb_convert_encoding($kw, 'utf-8', 'gbk');
		$res = $doctorSearchd->query($utf8Kw, ($p - 1) * 15, 15);
        $searchResult = SearchResult::sphinxResult2searchResult($res, 'doctor', ($p - 1) * 15, 15);
        $response->totalPage = ceil($searchResult->total_found/$searchResult->pageSize);
		
		$results = array();
		foreach($searchResult->items as $item)
		{/*{{{*/
			$doctor = DAL::get()->find('doctor',$item->id);
			
            if($doctor->isNull() || $doctor->deleted > 0 )
            {
				continue;
			}
			
			$result = array();
			$result['id'] = $doctor->id;
			$result['name'] = $doctor->name;
			$result['title'] = $doctor->title;
			$result['hospital'] = $doctor->hospitalfaculty->hospital->name;
			$result['userid'] = $doctor->getUserId();
			$result['hospitalfacultyname'] = $doctor->hospitalfaculty->name ;
			$results[] = (object)$result;
		}/*}}}*/
		return $results;
	}/*}}}*/
开发者ID:sdgdsffdsfff,项目名称:hdf-client,代码行数:29,代码来源:userdoctorcontroller.php

示例2: searchDoctor

    /**
        * @brief 搜索订阅医生
        * @author lhl
        * @exampleUrl http://dev.mobile-api.haodf.com/patientapi/subscription_searchdoctor?keyword=吴鸣&pageId=1&pageSize=15&userId=581662815 
        *
        * @param $keyword 搜索字段 
        * @Param $pageId 当前页码
        * @Param $pageSize 每页显示数
        *
        * @return array('doctorid', 'name', 'fullGrade', 'hospitalName', 'hospitalFacultyName', 'goodVoteCount', 'specialize', 'logoUrl')
     */
    public function searchDoctor($userId, $keyword, $pageId = 1, $pageSize = 15)
	{/*{{{*/
        if($userId != $this->currentUserId)
        {
            $this->setErrorCode(309);
            return 0;
        }
        if('' == trim($keyword))
        {
            $this->setErrorCode(450);
            return 0;
        }
        $doctorSearchd = SphinxSearchdBase::createSearchdByType('Doctor');
        $utf8Kw = mb_convert_encoding($keyword, 'utf-8', 'gbk');
		$res = $doctorSearchd->query($utf8Kw, (int)(($pageId - 1 ) * $pageSize), (int)($pageSize));
        $searchResult = SearchResult::sphinxResult2searchResult($res, 'doctor', (int)(($pageId - 1 ) * $pageSize), (int)($pageSize));
		
		$myDoctorList = SubscriptionClient::getInstance()->getMyDoctors($userId);
        $subscriptionDoctor = array();
        foreach($myDoctorList as $myDoctor) 
        {
           $subscriptionDoctor[$myDoctor->doctor->id] = $myDoctor->id;
        }

		$results = array();
		foreach($searchResult->items as $item)
		{
			$doctor = DAL::get()->find('doctor',$item->id);
			
            if(false == $doctor->isNull() && $doctor->deleted == 0)
            {
                $result = $allHospitalFacultyNames = array();
                $result['doctorid'] = $doctor->id;
                $result['name'] = $doctor->name;
                $result['fullGrade'] = implode(" ",array($doctor->grade,$doctor->educateGrade));
                $primaryDoctors = DAL::get()->find_all_byPrimaryIds('Doctor', array($doctor->primaryId));
                foreach ($primaryDoctors as $primaryDoctor)
                {
                    $allHospitalFacultyNames[] = $primaryDoctor->hospitalfaculty->hospital->commonName.' '.$primaryDoctor->hospitalfaculty->name;
                }
                $result['hospitalName'] = implode("\n", $allHospitalFacultyNames);
                $result['hospitalFacultyName'] = '';
                $result['goodVoteCount'] = $doctor->goodVoteCount;
                $result['specialize'] = $doctor->specialize;
                $result['logoUrl'] = $doctor->getHeadImageForMobile();
                $result['mydoctorid'] = '';
                if(isset($subscriptionDoctor[$doctor->id]))
                {
                    $result['mydoctorid'] = $subscriptionDoctor[$doctor->id];
                }
                $results[] = $result;
            }
		}
        $this->content = $results;
        $this->pageInfo = array('pages' => ceil($searchResult->total_found / $searchResult->pageSize), 'pagesize' => $pageSize, 'nowpage' => $pageId, 'total' => $searchResult->total_found);
	}/*}}}*/
开发者ID:sdgdsffdsfff,项目名称:hdf-client,代码行数:67,代码来源:subscriptiondatabucket.php


注:本文中的SearchResult::sphinxResult2searchResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。