标签:
$lastId = $arrInput[‘params‘][‘last_id‘];
$qlistRet = $this->_objApiQlUlist->getUlistStream($uid, null, self::PAGE_LIMIT+1, $lastId);
if($qlistRet[‘errno‘] != 0){ ---->接口调用出错情况
$errno = Dcna_ExceptionCodes::UNKNOWN_ERROR;
$errmsg = Dcna_ExceptionCodes::$errInfo[$errno];
$arrResult[‘errno‘] = $errno;
$arrResult[‘errmsg‘] = $errmsg;
return $arrResult;
}
if(empty($qlistRet[‘data‘])){ ---->数据为空情况
$errno = Dcna_ExceptionCodes::EMPTY_DATA_ERROR;
$errmsg = Dcna_ExceptionCodes::$errInfo[$errno];
$arrResult[‘errno‘] = $errno;
$arrResult[‘errmsg‘] = $errmsg;
return $arrResult;
}
---->下面的代码直接处理数据,而无需再对数据进行检查判断
if(count($qlistRet[‘data‘]) == self::PAGE_LIMIT+1 ){
$arrResult[‘data‘][‘has_more‘] = 1;
}
$qids = array();
$relQids = array();
$list_count = 0;
foreach($qlistRet[‘data‘] as $one){
$qids[] = $one[‘qid‘];
$relQids[$one[‘qid‘]] = $one;
$list_count++;
if($list_count == self::PAGE_LIMIT){
break;
}
}
标签:
原文地址:http://www.cnblogs.com/myhenghai/p/4488266.html