| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- include('../conn_mysqli.php');
- include('../phpMode/rcodeMap.php');
- $key = $_POST['key'];
- $type = $_POST['type'] ? $_POST['type'] : 'all';
- // 设置 $page 的默认值为1,并限定取值范围在1-10之间
- $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;
- header('Content-Type:text/json;charset=utf-8;');
- try {
- $resObj = array(
- 'rcode' => Rcode_OK,
- 'data' => "",
- 'msg' => 'ok'
- );
- set_time_limit(50);
- // echo "param:" . $key . "-" . $type . "-" . $limit . "-" . $offset . " ";
- //echo !empty($key)?"T":"F";
- // echo $type == "all" ? "T" : "F";
- //exit;
- $conn = createConn();
- $sql = "";
- $stmt = null;
- //echo "fuck php not conn ?";
- if ($type == "all") {
- // 无条件全选
- if (!empty($key)) {
- // echo " \n php is low \n";
- $sql = 'SELECT p.proid as id,p.remark,p.name,p.image,p.source,p.sourceType,p_type.type_key
- FROM mysql85931094_db.hfy_product as p , mysql85931094_db.hfy_product_type as p_type
- where p.type_id = p_type.type_id and p.name like \''.$key.'\' order by p.proid desc limit ?,?';
- } else {
- // echo " \n fuck php \n";
- $sql = 'SELECT p.proid as id,p.remark,p.name,p.image,p.source,p.sourceType,p_type.type_key
- FROM mysql85931094_db.hfy_product as p , mysql85931094_db.hfy_product_type as p_type
- where p.type_id = p_type.type_id order by p.proid desc limit ?,?';
- }
- $stmt = mysqli_prepare($conn, $sql);
- mysqli_stmt_bind_param($stmt, "dd", $offset, $limit);
- } else {
- if (!empty($key)) {
- // echo " \n fuck php ? \n";
- $sql = 'SELECT
- p.proid as id,p.remark,p.name,p.image,p.source,p.sourceType,p_type.type_key
- FROM mysql85931094_db.hfy_product as p ,
- mysql85931094_db.hfy_product_type as p_type
- where p.type_id = p_type.type_id and p_type.type_key = ? and p.name like \''.$key.'\' order by p.proid desc limit ?,?';
- $stmt = mysqli_prepare($conn, $sql);
- mysqli_stmt_bind_param($stmt, "ssdd", $type, $key, $offset, $limit);
- } else {
- // echo " \n fuck fuck fuck \n";
- $sql = 'SELECT
- p.proid as id,p.remark,p.name,p.image,p.source,p.sourceType,p_type.type_key
- FROM mysql85931094_db.hfy_product as p , mysql85931094_db.hfy_product_type as p_type
- where p.type_id = p_type.type_id and p_type.type_key = ? order by p.proid desc limit ?,?';
- $stmt = mysqli_prepare($conn, $sql);
- mysqli_stmt_bind_param($stmt, "sdd", $type, $offset, $limit);
- }
- }
- // echo "fuck_1";
- mysqli_stmt_execute($stmt);
- // echo " fuck_2";
- $res = mysqli_stmt_get_result($stmt);
- // echo " fuck_3";
- // echo "fuck ---------------";
- // echo $res;
- // echo "fuck " ;
- while ($row = mysqli_fetch_assoc($res)) {
- $rs[] = $row;
- }
- // echo "???????????????? ";
- // echo "???????????????? ".$res;
- mysqli_close($conn);
- $resObj['data'] = $rs;
- // echo "fuck ".$res;
- echo json_encode($resObj);
- }catch(Exception $e)
- {
- // echo 'Message: ' .$e->getMessage();
- echo 'server Error Message: notFound';
- }
- ?>
|