Esempio n. 1
0
 public static function import_all_db($directory)
 {
     $error = '';
     $dh = opendir($directory);
     //foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $filename)
     while (false !== ($filename = readdir($dh))) {
         if (preg_match('/\\.sql$/', $filename)) {
             $error .= create_db::import_file($directory . $filename);
         }
     }
     return $error;
 }
 private static function update_from_8()
 {
     $Connection = new Connection();
     $error = '';
     // Update table aircraft
     $error .= create_db::import_file('../db/notam.sql');
     if ($error != '') {
         return $error;
     }
     $query = "DELETE FROM config WHERE name = 'last_update_db';\n                        INSERT INTO config (name,value) VALUES ('last_update_db',NOW());\n                        DELETE FROM config WHERE name = 'last_update_notam_db';\n                        INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());";
     try {
         $sth = Connection::$db->prepare($query);
         $sth->execute();
     } catch (PDOException $e) {
         return "error (insert last_update values) : " . $e->getMessage() . "\n";
     }
     $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
     try {
         $sth = Connection::$db->prepare($query);
         $sth->execute();
     } catch (PDOException $e) {
         return "error (update schema_version) : " . $e->getMessage() . "\n";
     }
     return $error;
 }
 private static function update_from_9()
 {
     $Connection = new Connection();
     $query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;\n    \t\t\tALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
     try {
         $sth = $Connection->db->prepare($query);
         $sth->execute();
     } catch (PDOException $e) {
         return "error (add verticalrate column to spotter_live and spotter_output) : " . $e->getMessage() . "\n";
     }
     $error = '';
     // Update table atc
     $error .= create_db::import_file('../db/atc.sql');
     if ($error != '') {
         return $error;
     }
     $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
     try {
         $sth = $Connection->db->prepare($query);
         $sth->execute();
     } catch (PDOException $e) {
         return "error (update schema_version) : " . $e->getMessage() . "\n";
     }
     return $error;
 }
Esempio n. 4
0
 public static function update_countries()
 {
     global $tmp_dir;
     include_once 'class.create_db.php';
     update_db::gunzip('../db/countries.sql.gz', $tmp_dir . 'countries.sql');
     create_db::import_file($tmp_dir . 'countries.sql');
 }
 private static function update_from_10()
 {
     $Connection = new Connection();
     $query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
     try {
         $sth = $Connection->db->prepare($query);
         $sth->execute();
     } catch (PDOException $e) {
         return "error (add new enum to ATC table) : " . $e->getMessage() . "\n";
     }
     $error = '';
     // Add tables
     $error .= create_db::import_file('../db/aircraft_owner.sql');
     if ($error != '') {
         return $error;
     }
     $error .= create_db::import_file('../db/metar.sql');
     if ($error != '') {
         return $error;
     }
     $error .= create_db::import_file('../db/taf.sql');
     if ($error != '') {
         return $error;
     }
     $error .= create_db::import_file('../db/airport.sql');
     if ($error != '') {
         return $error;
     }
     $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
     try {
         $sth = $Connection->db->prepare($query);
         $sth->execute();
     } catch (PDOException $e) {
         return "error (update schema_version) : " . $e->getMessage() . "\n";
     }
     return $error;
 }