本文整理汇总了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;
}/*}}}*/
示例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);
}/*}}}*/