_loadByRow($src, $stripSlashes); } elseif (is_string($src)) { // Carichiamo tramite ID $sql = "SELECT * FROM " . self::TABLE_NAME . " WHERE CODICE = :CODICE"; $query = $con->prepare($sql); $query->bindParam(":CODICE", $src); try { $query->execute(); $it = $query->fetchAll(PDO::FETCH_ASSOC); Utils::FillObjectFromRow($this, $it[0]); } catch (Exception $exc) { $exc->getMessage(); } } } /** * * @param $CODICE * @return array */ public function LoadByCodice($CODICE) { global $con; $sql = "SELECT * FROM " . self::TABLE_NAME . " WHERE CODICE = :CODICE"; $query = $con->prepare($sql); $it = array(); $query->bindParam(":CODICE", $CODICE); try { $query->execute(); $it = $query->fetchAll(PDO::FETCH_ASSOC); Utils::FillObjectFromRow($this, $it[0]); } catch (Exception $exc) { $exc->getMessage(); } return $it; } /** * Restituisce la liste di tutti gli aeroporti * @return array */ public static function ListAeroporti($regione = '') { global $con; $filter = ''; if (!empty($regione)) { $filter = " WHERE REGIONE = :regione "; } $sql = "SELECT * FROM " . self::TABLE_NAME. ' '.$filter.' order by REGIONE, NOME'; $query = $con->prepare($sql); if (!empty($regione)) { $query->bindParam(":regione", $regione); } $return = array(); try { $query->execute(); $return = $query->fetchAll(PDO::FETCH_ASSOC); } catch (Exception $exc) { $exc->getMessage(); } return $return; } /** * Restituisce tutte le possibili destinazioni dell'aeroporto di partenza * @param $CODICE_A * @return array */ public static function ListDestinazione($CODICE_A) { global $con; $sql = "SELECT * FROM " . self::VIEW . " WHERE CODICE_A = :CODICE_A"; $query = $con->prepare($sql); $return = array(); $query->bindParam(":CODICE_A", $CODICE_A); try { $query->execute(); $return = $query->fetchAll(PDO::FETCH_ASSOC); } catch (Exception $exc) { $exc->getMessage(); } return $return; } public static function autocomplete($string = '', $regione = null) { global $con; $return = array(); $filter = ''; $searchFix = ''; if (!empty($regione)) { $filter = " REGIONE = :regione AND "; } $string = "%" . strtolower($string) . "%"; $sql = "SELECT * FROM " . self::TABLE_NAME . " WHERE " . $filter . " LOWER(NOME) LIKE :term ".$searchFix." ORDER BY REGIONE, NOME"; $query = $con->prepare($sql); if (!empty($regione)) { $query->bindParam(":regione", $regione); } $query->bindParam(":term", $string); try { $query->execute(); while ($it = $query->fetch(PDO::FETCH_ASSOC)) { $descrizione = $it['NOME']; $row['id'] = $descrizione; $row['text'] = $descrizione; $row['label'] = $descrizione; $row['codice'] = $it['CODICE']; array_push($return, $row); } } catch (Exception $exc) { echo $exc->getMessage(); } return $return; } public static function autocompleteRitorno($string = '', $codice_a = null) { global $con; $return = array(); $filter = ''; $searchFix = ''; if (!empty($codice_a)) { $filter = " A_CODICE = :codice_a AND "; }else{ return $return; } $string = "%" . strtolower($string) . "%"; $sql = "SELECT * FROM " . self::VIEW . " WHERE " . $filter . " LOWER(R_NOME) LIKE :term ".$searchFix." ORDER BY R_NOME"; $query = $con->prepare($sql); if (!empty($codice_a)) { $query->bindParam(":codice_a", $codice_a); } $query->bindParam(":term", $string); try { $query->execute(); while ($it = $query->fetch(PDO::FETCH_ASSOC)) { $descrizione = $it['R_NOME']; $row['id'] = $descrizione; $row['text'] = $descrizione; $row['label'] = $descrizione; $row['codice'] = $it['R_CODICE']; array_push($return, $row); } } catch (Exception $exc) { echo $exc->getMessage(); } return $return; } public function Parse(&$record, $campo = "") { array_push($record, array("Campo" => $campo, "Valore" => $this->$campo)); } }