# url参数 >[info] 提示: 模型继承 api\common\model\CommonModel.php 可简化以下参数处理。 ## 主参数列表 | 参数名 |用途 | 示例 | 注意事项 | | --- | --- | --- | --- | | field | 过滤查询结果字段 | field=id,user_id,name | 默认为所有字段 | | ids | 指定查询id | ids=1,2,3 | | | limit | 限制查询条数 | limit=8或limit=1,5 | 当参数中存在page时,此参数无效 | | page | 分页查询 | page=1或page=1,8 | `page=1`表示加载第一页数据,每页数量为默认;`page=1,8`表示加载第一页数据,每页数量为8 | | order | 结果排序 | order=+id 或 order=-id | + 升序 (不可省略) - 降序 | | relation | 关联内容 | relation=articles | 需要设置模型 | ## 请求示例 >[success]field:过滤查询结果字段 ~~~php url: http://thinkcmfapi.com/api/portal/categories?field=id,name ~~~ 返回结果: ~~~json { "code":1, "msg":"请求成功!", "data":[ { "id":8, "name":"视频" }, { "id":9, "name":"热点" }, { "id":10, "name":"本地" } ] } ~~~ >[success]ids: 指定查询id ~~~php url: http://thinkcmfapi.com/api/portal/categories?field=id,name&ids=8,9 ~~~ 返回结果: ~~~json { "code":1, "msg":"请求成功!", "data":[ { "id":8, "name":"视频" }, { "id":9, "name":"热点" } ] } ~~~ >[success]limit: 限制结果数量 ~~~php url: http://thinkcmfapi.com/api/portal/categories?field=id,name&limit=1 ~~~ 返回结果: ~~~json { "code":1, "msg":"请求成功!", "data":[ { "id":8, "name":"视频" } ] } ~~~ >[success]page: 结果分页 ~~~php url: http://thinkcmfapi.com/api/portal/categories?field=name,id&page=2,10 ~~~ ?page=2,10 返回:第2页,每页10条记录 ~~~json { "code":1, "msg":"请求成功!", "data":[ { "id":8, "name":"视频" } ] } ~~~ >[success]order: 结果排序 ~~~php url: http://thinkcmfapi.com/api/portal/categories?field=name,id&order=-id ~~~ &order=-id 返回:按字段id降序排列的结果 +升序 ,-降序 ~~~json { "code":1, "msg":"请求成功!", "data":[ { "name":"本地", "id":10 }, { "name":"热点", "id":9 }, { "name":"视频", "id":8 } ] } ~~~ >[success]relation: 关联内容 ~~~php url: http://thinkcmfapi.com/api/portal/articles?field=name,id&order=-id&relation=categories ~~~ &relation=categories 返回:文章关联分类 ~~~json { "code":1, "msg":"请求成功!", "data":[ { "id":32, "post_type":1, "user_id":1, "comment_status":1, "is_top":0, "recommended":1, "post_hits":14, "post_like":0, "comment_count":0, "create_time":1496752820, "update_time":1500413076, "published_time":"2017-06-06 20:40:00", "post_title":"fasdf", "post_keywords":"test3,古典", "post_excerpt":"", "post_source":"", "post_content":" <p><img src="https://www.thinkcmf.com/upload/portal/20170517/72572943055cc7548cb637a82cfe3882.png" title="hdImg_5c4d7cf6f6cc9b7b7dff3b0b4d7eccc214646007082.jpg" alt="hdImg_5c4d7cf6f6cc9b7b7dff3b0b4d7eccc214646007082.jpg"></p> <p><br></p> <p><a href="http://www.baidu.com" target="_self">test</a><br></p> ", "more":{ "thumbnail":"", "template":"" }, "categories":[ { "id":2, "post_count":0, "name":"瀑布流", "description":"瀑布流", "seo_title":"", "seo_keywords":"", "seo_description":"", "more":{ "thumbnail":"" } }, { "id":6, "post_count":0, "name":"发现", "description":"发现", "seo_title":"发现", "seo_keywords":"地", "seo_description":"地", "more":{ "thumbnail":"" } } ] } ] } ~~~