ねえ、私は SQL と PHP にかなり慣れていませんが、これを書きましたが、正しく動作していないようです。「成功」をエコーしますが、データベースをチェックして情報が送信されたかどうかを確認すると、テーブルに何も返されません。
function update($script_name, $version, $runtime, $status, $sessionID, $ranged, $attack, $defense, $strength, $magic)
{
global $db;
$sql = "SELECT * FROM Dashboard WHERE script_name = '$script_name'";
try {
$results = $db->query($sql);
if ($results->rowCount() <= 0) {
$query = "INSERT INTO Dashboard (script_name, version, runtime, status, session_id, range, attack, defense, strength, magic) VALUES ('$script_name', '$version', '$runtime', '$status', '$ranged', '$sessionID', '$attack', '$defense', '$strength', '$magic')";
$db->exec($query);
} else {
foreach ($results as $row) {
$timerunnew = $row['runtime'] + $runtime;
$v1new = $row['script_name'] + $script_name;
$v2new = $row['version'] + $version;
$v3new = $row['status'] + $status;
$v4new = $row['range'] + $range;
$v5new = $row['attack'] + $attack;
$v6new = $row['defense'] + $defense;
$v7new = $row['strength'] + $strength;
$v8new = $row['magic'] + $magic;
$v9new = $row['session_id'] + $sessionID;
}
$db->exec("UPDATE Dashboard SET `runtime` = $timerunnew, `script_name` = $v1new, `version` = $v2new, `status` = $v3new, `range` = $v4new, `attack` = $v5new, `defense` = $v6new, `strength` = $v7new, `magic` = $v8new, `session_id` = $v9new WHERE script_name = '$script_name'");
}
} catch (PDOException $ex) {
echo "fail";
}
}
どんな助けでも大歓迎です。