0) { $this->_loadAndFillObject($src['ID'], self::TABLE_NAME, $src); } else { $this->_loadByRow($src, $stripSlashes); } } elseif (intval($src)) { $sql = "SELECT * FROM " . self::TABLE_NAME . " WHERE ID = :id"; $query = $con->prepare($sql); $query->bindParam(":id", $src); try { $query->execute(); $it = $query->fetchAll(PDO::FETCH_ASSOC); Utils::FillObjectFromRow($this, $it[0]); } catch (Exception $exc) { $exc->getMessage(); } } } public static function autocomplete($string = '', $andata = null, $ritorno = null) { global $con; $return = array(); $filter = ''; $searchFix = ''; if (!empty($andata) && !empty($ritorno)) { $filter = " (AEROPORTO = :andata OR AEROPORTO = :ritorno) AND "; }else{ return $return; } $string = "%" . strtolower($string) . "%"; $sql = "SELECT A.* FROM " . self::TABLE_NAME . " A INNER JOIN ".AeroportiCompagnie::TABLE_NAME." B ON B.COMPAGNIA = A.ID WHERE " . $filter . " LOWER(A.NOME) LIKE :term ".$searchFix." ORDER BY A.NOME"; $query = $con->prepare($sql); if (!empty($andata) && !empty($ritorno)) { $query->bindParam(":andata", $andata); $query->bindParam(":ritorno", $ritorno); } $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['ID']; 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)); } } class AeroportiCompagnie extends DataClass { const TABLE_NAME = "AEROPORTI_COMPAGNIE"; public $AEROPORTO = ""; public $COMPAGNIA = 0; public function __construct($src = null) { global $con; $stripSlashes = false; if ($src == null) { return; } if (is_array($src)) { $this->_loadByRow($src, $stripSlashes); } } public function Parse(&$record, $campo = "") { array_push($record, array("Campo" => $campo, "Valore" => $this->$campo)); } }