关闭
duansai1314 2015-03-16 05:39
浏览 57
已采纳

从parse.com获取数据时添加orderby子句

I am tryng to fetch data from parse.com but its not allow to skip more than 10000 data so for doing it in a alternate way i have to use order by

My code is

$request = 'skip='.$max.'&limit=1000';

$url = "https://api.parse.com/1/classes/_Installation" . "?".$request;
// $ch = curl_init($url); 
curl_setopt($ch,CURLOPT_URL,$url); 
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);  
$response = curl_exec($ch);  

$parse_data=json_decode($response,true);

I'm trying to use this concept https://www.parse.com/questions/paging-through-more-than-10000-results

but i don't know how to use orderby in curl code.

please help

  • 写回答

1条回答 默认 最新

  • dongteng2534 2015-03-16 06:06
    关注

    As API docs say:

    You can sort by multiple fields by passing order a comma-separated list. To retrieve documents that are ordered by scores in ascending order and the names in descending order:

    Example for you:

    $request = 'skip='.$max.'&limit=1000&order=your_order_field';
    

    You can choose if order should be ascending or descending by adding -:

    $request = 'skip='.$max.'&limit=1000&order=your_order_field';//ASC
    $request = 'skip='.$max.'&limit=1000&order=-your_order_field';//DESC
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部