| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- include('../conn_mysqli.php');
- include('../phpMode/rcodeMap.php');
- // 目前基于设备管理的下载项
- $page = isset($_POST['page']) ? max(1, min(10, intval($_POST['page']))) : 1;
- // 设置 $limit 的默认值为20,并限定取值范围在1-100之间
- $limit = isset($_POST['limit']) ? max(1, min(100, intval($_POST['limit']))) : 20;
- $offset = ($page - 1) * $limit;
- $id = $_POST['id'];
- header('Content-Type:text/json;charset=utf-8;');
- $resObj = array(
- 'rcode' => Rcode_OK,
- 'data' => "",
- 'msg' => 'ok'
- );
- if(!isset($_POST['id'])){
- $resObj['rcode'] = Rcode_NotParam;
- $resObj['data'] = "";
- $resObj['msg'] = "id is must set";
- echo json_encode($resObj);
- exit;
- }
- try {
- set_time_limit(50);
- $conn = createConn();
- $sql = "";
- $stmt = null;
- // 获取id为
- $sql = 'select * from mysql85931094_db.hfy_downloads where p_id = ? order by id desc limit ?,?';
- $stmt = mysqli_prepare($conn, $sql);
- mysqli_stmt_bind_param($stmt, "sdd",$id, $offset, $limit);
- mysqli_stmt_execute($stmt);
- $res = mysqli_stmt_get_result($stmt);
- while ($row = mysqli_fetch_assoc($res)) {
- $rs[] = $row;
- }
- mysqli_close($conn);
- $resObj['data'] = $rs;
- echo json_encode($resObj);
- }catch(Exception $e)
- {
- // echo 'Message: ' .$e->getMessage();
- $resObj['rcode'] = Rcode_ServerError;
- $resObj['msg'] = 'server error';
- echo json_encode($resObj);
- }
|