【发布时间】:2017-01-02 15:33:22
【问题描述】:
如何通过分页从 Web 服务中检索数据?现在我可以显示数据。但我不能进行分页。 我正在使用带有 curl 库的 codeigniter 3.0.6。这是我用来制作 REST API 的:
function index_get($limit = 100, $offset = 0) {
$MhswID = $this->get('MhswID');
if ($MhswID == '') {
$mhsw = $this->db->get('mhsw', $limit, $offset)->result();
} else {
$this->db->where('MhswID', $MhswID);
$mhsw = $this->db->get('mhsw', $limit, $offset)->result();
}
$this->response($mhsw, 200);
}
这是用于检索数据:
function __construct() {
parent::__construct();
$this->API="http://admin:1234@localhost/ci3_rest/index.php";
}
// menampilkan data mahasiswa
function index($limit = "", $offset = ""){
$data['mahasiswa'] = json_decode($this->curl->simple_get($this->API.'/mahasiswa'));
$this->load->view('welcome_message',$data);
}
【问题讨论】:
-
请提供更多详细信息并显示您的代码。
-
编辑了@parth。请检查。
标签: codeigniter rest api curl