function test() { $db = db_connect(); $this->assertEqual(gcDistance($db, 1, 1), array(0, gcDuration(0))); }
?, ?, ?, NOW()) QUERY; $sth = $dbh->prepare($sql); foreach ($rows as $idx) { $src_date = $_POST["src_date" . $idx]; $src_apid = $_POST["src_apid" . $idx]; $dst_apid = $_POST["dst_apid" . $idx]; $alid = trim($_POST["alid" . $idx]); if ($alid == 0) { $alid = -1; } // this should not be necessary, but just in case... // If either the distance or duration is missing, try to calculate it by airports. if (!$_POST["duration"] || !$_POST["distance"]) { list($calc_distance, $calc_duration) = gcDistance($dbh, $src_apid, $dst_apid); if (!$_POST["duration"]) { $duration = $calc_duration; } if (!$_POST["distance"]) { $distance = $calc_distance; } } list($src_apid, $dst_apid, $opp) = orderAirports($src_apid, $dst_apid); if ($idx != "" && $idx != "1") { $sql .= ","; } $success = $sth->execute(array($uid, $src_apid, $src_date, $src_time, $dst_apid, $duration, $distance, $registration, $number, $seat, $seat_type, $class, $reason, $note, $plid, $alid, $trid, $opp, $mode)); if (!$success) { # PDO will print a warning with the error. error_log("Could not insert flight for user {$uid}.");
} // Skip first row for CSV if ($fileType == "CSV" && $count == 1) { continue; } //Check if parsing succeeded and tag fatal errors if not if (!$src_date) { $status = "disabled"; $fatal = "date"; } if (!$src_apid || !$dst_apid) { $status = "disabled"; $fatal = "airport"; } else { if ($duration == "" || $distance == "") { list($distance, $duration) = gcDistance($db, $src_apid, $dst_apid); $dist_bgcolor = "#ddf"; } else { $dist_bgcolor = "#fff"; } } if (!$alid) { $status = "disabled"; $fatal = "airline"; } if ($trid && $trip_bgcolor != "#fff") { $status = "disabled"; $fatal = "trip"; } switch ($action) { case _("Upload"):