table}"; $count = $CageModel->query($sql); $sql = "select * from {$CageModel->table} order by id desc limit {$offset},{$limit} "; $data = $CageModel->query($sql); foreach($data as $key => &$val){ $val['type'] = $val['type']==1?'库存笼':'繁殖笼'; } $return['code'] = 0; $return['count'] = count($count); $return['data'] = $data; $return['msg'] = "成功"; echo json_encode($return);die; } public function editAction(){ $CageModel = new CageModel(); $data['id'] = empty($_POST['id'])||!isset($_POST['id'])?Tool_Fnc::apiMsg('系统错误', '500'):Tool_Fnc::safe_string($_POST['id']); $field = empty($_POST['field'])||!isset($_POST['field'])?Tool_Fnc::apiMsg('系统错误', '500'):Tool_Fnc::safe_string($_POST['field']); $status = empty($_POST['status'])||!isset($_POST['status'])?0:Tool_Fnc::safe_string($_POST['status']); $data[$field] = $status; if(!$CageModel->update($data)) Tool_Fnc::ajaxMsg('变更失败', '500'); Tool_Fnc::ajaxMsg('变更成功', '1'); } }