mongo中的分页查询
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mongo中的分页查询相关的知识,希望对你有一定的参考价值。
/** * @param $uid * @param $app_id * @param $start_time * @param $end_time * @param $start_page * @param $limit_page * mongodb中的分页查询 */ public static function getUserRevenueInfoList($uid, $source,$app_id, $start_time, $end_time,$skip, $limit){ $match = [‘app_id‘=>$app_id, ‘uid‘=>(int)$uid, ‘msg_id‘=>1009, ‘source‘ => intval($source), "timestamp" => [‘$gte‘ => (int)$start_time, ‘$lt‘ => (int)$end_time], ]; $conditions = array( array(‘$match‘=>$match), ); //分页查询的参数 if($skip > 0) $conditions[] = array(‘$skip‘=>(int)$skip); if($limit > 0) $conditions[] = array(‘$limit‘=>(int)$limit); //指定返回的字段 $project = [ ‘miss‘=>‘$miss‘, ‘win‘=>‘$miss‘, ‘bet‘=>‘$bet‘, ‘user_win‘=>‘$user_win‘, ‘time‘=>‘$timestamp‘, ]; $conditions[] = array(‘$project‘=>$project); $result=self::aggregate($conditions); $final_data = []; foreach($result[‘result‘] as $log){ $temp = []; $temp["miss"] = (int)\Utilities::mongoGetNumber($log[‘miss‘]); $temp["win"] = (int)\Utilities::mongoGetNumber($log[‘win‘]); $temp["bet"] = (int)\Utilities::mongoGetNumber($log[‘bet‘]); $temp["user_win"] = (int)\Utilities::mongoGetNumber($log[‘user_win‘]); $temp["time"] = date("Y-m-d H:i:s",(int)\Utilities::mongoGetNumber($log["time"])); $final_data[]=$temp; } return $final_data; }
以上是关于mongo中的分页查询的主要内容,如果未能解决你的问题,请参考以下文章