query($s); $r = $q->fetchArray(SQLITE3_ASSOC); $team_id = $r["id"]; $statement = $db->prepare(" 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 = :uid AND run.id = :run AND k_area.id = run.area AND run.helper = 0; "); $statement->bindValue(':uid', $player, SQLITE3_INTEGER); $statement->bindValue(':run', $run, SQLITE3_INTEGER); $r = $statement->execute()->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, SQLITE3_INTEGER); $statement->bindValue(':id', $team_id, SQLITE3_INTEGER); $statement->bindValue(':name', $name, SQLITE3_TEXT); $statement->bindValue(':description', $description, SQLITE3_TEXT); $statement->bindValue(':area_type', $r["area_type"], SQLITE3_INTEGER); $statement->bindValue(':area', $r["area"], SQLITE3_INTEGER); $statement->bindValue(':stage', $r["stage"], SQLITE3_INTEGER); $statement->bindValue(':difficulty', $r["difficulty"], SQLITE3_INTEGER); $statement->bindValue(':score', 0, SQLITE3_INTEGER); $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)){ $statement = $db->prepare(" INSERT INTO team_unit (team, unit) VALUES (:team, :unit) "); $statement->bindValue(':team', $team_id, SQLITE3_INTEGER); $statement->bindValue(':unit', $r["unit"], SQLITE3_INTEGER); $statement->execute(); } return 0; } ?>