本文整理汇总了PHP中OperationsData::editAirport方法的典型用法代码示例。如果您正苦于以下问题:PHP OperationsData::editAirport方法的具体用法?PHP OperationsData::editAirport怎么用?PHP OperationsData::editAirport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OperationsData
的用法示例。
在下文中一共展示了OperationsData::editAirport方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit_airport_post
/**
* Operations::edit_airport_post()
*
* @return
*/
protected function edit_airport_post()
{
if ($this->post->icao == '' || $this->post->name == '' || $this->post->country == '' || $this->post->lat == '' || $this->post->lng == '') {
$this->set('message', 'Some fields were blank!');
$this->render('core_message.php');
return;
}
if ($this->post->hub == 'true') {
$this->post->hub = true;
} else {
$this->post->hub = false;
}
$data = array('icao' => $this->post->icao, 'name' => $this->post->name, 'country' => $this->post->country, 'lat' => $this->post->lat, 'lng' => $this->post->lng, 'hub' => $this->post->hub, 'chartlink' => $this->post->chartlink, 'fuelprice' => $this->post->fuelprice);
OperationsData::editAirport($data);
if (DB::errno() != 0) {
$this->set('message', 'There was an error adding the airport: ' . DB::$error);
$this->render('core_error.php');
return;
}
$this->set('message', '"' . $this->post->icao . '" has been edited');
$this->render('core_success.php');
LogData::addLog(Auth::$userinfo->pilotid, 'Edited the airport "' . $this->post->icao . ' - ' . $this->post->name . '"');
}
示例2: importairports
public function importairports()
{
if (!file_exists($_FILES['uploadedfile']['tmp_name'])) {
$this->render('airport_import_form.php');
return;
}
echo '<h3>Processing Import</h3>';
# Get the column headers
$allaircraft = OperationsData::getAllAirports(false);
$headers = array();
$dbcolumns = DB::get_cols();
foreach ($dbcolumns as $col) {
$headers[] = $col->name;
}
$temp_name = $_FILES['uploadedfile']['tmp_name'];
$new_name = CACHE_PATH . '/' . $_FILES['uploadedfile']['name'];
if (!move_uploaded_file($temp_name, $new_name)) {
$this->render('core_error.php');
$this->set('message', 'Shit the bed?');
return false;
}
$fp = fopen($new_name, 'r');
if (isset($_POST['header'])) {
$skip = true;
}
$added = 0;
$updated = 0;
$total = 0;
echo '<div style="overflow: auto; height: 400px;
border: 1px solid #666; margin-bottom: 20px;
padding: 5px; padding-top: 0px; padding-bottom: 20px;">';
if (isset($_POST['erase_airports'])) {
OperationsData::deleteAllAirports();
echo "Deleting All Airports<br />";
}
while ($fields = fgetcsv($fp, 1000, ',')) {
// Skip the first line
if ($skip == true) {
$skip = false;
continue;
}
//Check for empty lines, continue
if (empty($fields)) {
continue;
}
//Create Varibles...
$icao = $fields[0];
$name = $fields[1];
$country = $fields[2];
$lat = $fields[3];
$lng = $fields[4];
$hub = $fields[5];
$fuelprice = $fields[6];
$chartlink = $fields[7];
//Since we need the values filled in, if not, then continue
if (empty($icao) || empty($lat) || empty($lng)) {
continue;
}
# Enabled or not
if ($hub == '1') {
$hub = true;
} else {
$hub = false;
}
//Build Array, seem can't use the array merge for some reason...
$data = array('icao' => $fields[0], 'name' => $fields[1], 'country' => $fields[2], 'lat' => $fields[3], 'lng' => $fields[4], 'hub' => $hub, 'fuelprice' => $fields[6], 'chartlink' => $fields[7]);
# Does this airport exist?
$aiport_info = OperationsData::getAirportInfo($icao);
if ($aiport_info) {
echo "Editing {$icao} - {$name}<br>";
OperationsData::editAirport($data);
$updated++;
} else {
echo "Adding {$icao} - {$name}<br>";
OperationsData::addAirport($data);
$added++;
}
$total++;
}
//You should always close a file before deleting otherwise it will spit the unlink error due to permissions
fclose($fp);
unlink($new_name);
echo "The import process is complete, added {$added} airports, updated {$updated}, for a total of {$total}<br />";
}