function do_unit_test($case) { switch ($case) { case 1: $fArray = array(); $cArray = array(); respDBData($fArray, $cArray); break; case 2: respFieldList("pId"); break; case 3: respFieldList("gSn"); break; case 4: break; } }
$respJSON["has_updated"] = $_POST["userID"]; break; */ case "selectDb": // $fArray = array(); $cKeys = array("pId", "measure_date", "gSn"); //init the associative array with keys in $cKeys and all the default value: null $cArray = array_fill_keys($cKeys, ""); //取得查詢的條件 if (!$self_test) { $cArray["pId"] = $_POST["id_list"]; $cArray["measure_date"] = $_POST["measure_date"]; $cArray["gSn"] = $_POST["dev_list"]; } else { $cArray["pId"] = "6123456789012389"; $cArray["measure_date"] = "2015-10-19"; $cArray["gSn"] = "0"; } //print_r($cArray); $respJSON["data"] = respDBData($fArray, $cArray); break; default: //Notice: Should not happen!!! echo "Unknow request action! Check it out"; return; } echo json_encode($respJSON); //回傳JSON格式 ?>