当前位置: 首页>>代码示例>>PHP>>正文


PHP Spotter::countryFromAircraftRegistration方法代码示例

本文整理汇总了PHP中Spotter::countryFromAircraftRegistration方法的典型用法代码示例。如果您正苦于以下问题:PHP Spotter::countryFromAircraftRegistration方法的具体用法?PHP Spotter::countryFromAircraftRegistration怎么用?PHP Spotter::countryFromAircraftRegistration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Spotter的用法示例。


在下文中一共展示了Spotter::countryFromAircraftRegistration方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addModeSData

 /**
  * Add ModeS data to DB
  *
  * @param String $ident ident
  * @param String $registration Registration of the aircraft
  * @param String $icao
  * @param String $ICAOTypeCode
  */
 public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '')
 {
     global $globalDebug, $globalDBdriver;
     $ident = trim($ident);
     $Translation = new Translation();
     $Spotter = new Spotter();
     if ($globalDebug) {
         echo "Test if we add ModeS data...";
     }
     //if ($icao == '') $icao = ACARS->ident2icao($ident);
     if ($icao == '') {
         $icao = $Translation->checkTranslation($ident);
     }
     if ($globalDebug) {
         echo '- Ident : ' . $icao . ' - ';
     }
     if ($ident == '' || $registration == '') {
         if ($globalDebug) {
             echo "Ident or registration null, exit\n";
         }
         return '';
     }
     $registration = str_replace('.', '', $registration);
     $ident = $Translation->ident2icao($ident);
     // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
     if ($globalDebug) {
         echo "Check if needed to add translation " . $ident . '... ';
     }
     $querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration LIMIT 1";
     $querysi_values = array(':registration' => $registration);
     try {
         $sthsi = $this->db->prepare($querysi);
         $sthsi->execute($querysi_values);
     } catch (PDOException $e) {
         if ($globalDebug) {
             echo $e->getMessage();
         }
         return "error : " . $e->getMessage();
     }
     $resultsi = $sthsi->fetch(PDO::FETCH_ASSOC);
     //print_r($resultsi);
     if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') {
         $Translation = new Translation();
         $trans_ident = $Translation->getOperator($resultsi['ident']);
         if ($globalDebug) {
             echo 'Add translation to table : ' . $ident . ' -> ' . $resultsi['ident'] . ' ';
         }
         if ($ident != $trans_ident) {
             $Translation->addOperator($resultsi['ident'], $ident, 'ACARS');
         } elseif ($trans_ident == $ident) {
             $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS');
         }
     }
     if ($globalDebug) {
         echo 'Done' . "\n";
     }
     $query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident =  :ident ORDER BY spotter_id DESC LIMIT 1";
     $query_values = array(':ident' => $icao);
     try {
         $sth = $this->db->prepare($query);
         $sth->execute($query_values);
     } catch (PDOException $e) {
         if ($globalDebug) {
             echo $e->getMessage();
         }
         return "error : " . $e->getMessage();
     }
     $result = $sth->fetch(PDO::FETCH_ASSOC);
     //print_r($result);
     if (isset($result['flightaware_id'])) {
         if (isset($result['ModeS'])) {
             $ModeS = $result['ModeS'];
         } else {
             $ModeS = '';
         }
         if ($ModeS == '') {
             $id = explode('-', $result['flightaware_id']);
             $ModeS = $id[0];
         }
         if ($ModeS != '') {
             $country = $Spotter->countryFromAircraftRegistration($registration);
             $queryc = "SELECT * FROM aircraft_modes WHERE ModeS = :modes LIMIT 1";
             $queryc_values = array(':modes' => $ModeS);
             try {
                 $sthc = $this->db->prepare($queryc);
                 $sthc->execute($queryc_values);
             } catch (PDOException $e) {
                 if ($globalDebug) {
                     echo $e->getMessage();
                 }
                 return "error : " . $e->getMessage();
             }
//.........这里部分代码省略.........
开发者ID:linuxpronl,项目名称:FlightAirMap,代码行数:101,代码来源:class.ACARS.php

示例2: addModeSData

 /**
  * Add ModeS data to DB
  *
  * @param String $ident ident
  * @param String $registration Registration of the aircraft
  * @param String $icao
  * @param String $ICAOTypeCode
  */
 public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '')
 {
     global $globalDebug;
     $Translation = new Translation();
     $Spotter = new Spotter();
     if ($globalDebug) {
         echo "Test if we add ModeS data...";
     }
     //if ($icao == '') $icao = ACARS->ident2icao($ident);
     if ($icao == '') {
         $icao = $Translation->checkTranslation($ident);
     }
     if ($globalDebug) {
         echo '- Ident : ' . $icao . ' - ';
     }
     if ($ident == '' || $registration == '') {
         if ($globalDebug) {
             echo "Ident or registration null, exit\n";
         }
         return '';
     }
     $query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident =  :ident ORDER BY spotter_id DESC LIMIT 1";
     $query_values = array(':ident' => $icao);
     try {
         $sth = $this->db->prepare($query);
         $sth->execute($query_values);
     } catch (PDOException $e) {
         if ($globalDebug) {
             echo $e->getMessage();
         }
         return "error : " . $e->getMessage();
     }
     $result = $sth->fetch(PDO::FETCH_ASSOC);
     //print_r($result);
     if (isset($result['flightaware_id'])) {
         $ModeS = $result['ModeS'];
         if ($ModeS == '') {
             $id = explode('-', $result['flightaware_id']);
             $ModeS = $id[0];
         }
         if ($ModeS != '') {
             $country = $Spotter->countryFromAircraftRegistration($registration);
             $queryc = "SELECT * FROM aircraft_modes WHERE ModeS = :modes LIMIT 1";
             $queryc_values = array(':modes' => $ModeS);
             try {
                 $sthc = $this->db->prepare($queryc);
                 $sthc->execute($queryc_values);
             } catch (PDOException $e) {
                 if ($globalDebug) {
                     echo $e->getMessage();
                 }
                 return "error : " . $e->getMessage();
             }
             $row = $sthc->fetch(PDO::FETCH_ASSOC);
             if (count($row) == 0) {
                 if ($globalDebug) {
                     echo " Add to ModeS table - ";
                 }
                 $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
                 $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
                 try {
                     $sthi = $this->db->prepare($queryi);
                     $sthi->execute($queryi_values);
                 } catch (PDOException $e) {
                     if ($globalDebug) {
                         echo $e->getMessage();
                     }
                     return "error : " . $e->getMessage();
                 }
             } else {
                 if ($globalDebug) {
                     echo " Update ModeS table - ";
                 }
                 if ($ICAOTypeCode != '') {
                     $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
                     $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
                 } else {
                     $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
                     $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration);
                 }
                 try {
                     $sthi = $this->db->prepare($queryi);
                     $sthi->execute($queryi_values);
                 } catch (PDOException $e) {
                     if ($globalDebug) {
                         echo $e->getMessage();
                     }
                     return "error : " . $e->getMessage();
                 }
             }
             if ($globalDebug) {
                 echo " Update Spotter_live table - ";
//.........这里部分代码省略.........
开发者ID:sysrun,项目名称:FlightAirMap,代码行数:101,代码来源:class.ACARS.php


注:本文中的Spotter::countryFromAircraftRegistration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。