query($s); $r = $q->fetchArray(SQLITE3_ASSOC); $team_id = $r["id"]; $s = "SELECT run.area AS area, run.stage AS stage, run.difficulty AS difficulty, k_area.type AS area_type FROM run, k_area WHERE run.uid = '$player' AND run.id = '$run' AND k_area.id = run.area AND run.helper = 0;"; $q = $db->query($s); $r = $q->fetchArray(SQLITE3_ASSOC); if (!$r){ return -2; } $statement = $db->prepare('INSERT INTO team (uid, id, name, description, area_type, area, stage, difficulty, score) VALUES (:uid, :id, :name, :description, :area_type, :area, :stage, :difficulty, :score);'); $statement->bindValue(':uid', $player); $statement->bindValue(':id', $team_id); $statement->bindValue(':name', $name); $statement->bindValue(':description', $description); $statement->bindValue(':area_type', $r["area_type"]); $statement->bindValue(':area', $r["area"]); $statement->bindValue(':stage', $r["stage"]); $statement->bindValue(':difficulty', $r["difficulty"]); $statement->bindValue(':score', $score); $res = $statement->execute(); if (!$res){ return -3; } $s = "SELECT unit FROM run_party WHERE run = $run AND unit IS NOT NULL;"; $q = $db->query($s); while ($r = $q->fetchArray(SQLITE3_ASSOC)){ $s = "INSERT INTO team_unit VALUES ('$team_id', '" . $r["unit"] . "');"; $db->query($s); } return 0; } ?>