PDO に切り替えましたが、1 回の実行で複数の行を挿入する SQL クエリの作成と実行に問題があります。
$data
json_decode 後の内容:
Array (
[action] => load
[app] => CA
[street_type] => AVE
[place_type] => --
[state] => AL
)
コード:
$data = json_decode(file_get_contents("php://input"));
$query = "REPLACE INTO tblsettings(setApp, setIP, setKey, setValue)VALUES";
$qPart = array_fill(0, count($data), "(?, ?, ?, ?)");
$query .= implode(",", $qPart);
$stmt = $db->prepare($query);
foreach($data as $key => $val){
$query = "REPLACE INTO tblsettings(setApp, setIP, setKey, setValue)VALUES";
$qPart = array_fill(0, count($data), "(?, ?, ?, ?)");
$query .= implode(",", $qPart);
$stmt = $db->prepare($query);
$i = 1;
if(!is_array($val)){
$stmt->bindParam($i++, $data->app);
$stmt->bindParam($i++, gethostbyname(trim(gethostname())));
$stmt->bindParam($i++, $key);
$stmt->bindParam($i++, $val);
}
if ($stmt->execute()){
echo "Success";
}else{
echo $stmt->errorCode();
}
}