Пример #1
0
 /**
  *
  */
 public static function checkLogin($codiceFiscale, $password)
 {
     $q = '
         SELECT
             id,
             tipologia
         FROM utenze
         WHERE codice_fiscale = :codice_fiscale
             AND password = :password
         LIMIT 1
         ';
     $hash = md5($password);
     $sth = DB::instance()->prepare($q);
     $sth->bindParam(':codice_fiscale', $codiceFiscale);
     $sth->bindParam(':password', $hash);
     $sth->execute();
     $result = $sth->fetch();
     return $result;
 }
Пример #2
0
 /**
  *
  */
 private static function getLatLon($indirizzo, $civico)
 {
     $q = '
         SELECT ST_AsGeoJSON(ST_Transform(geom, 4326)) json
         FROM civici c
         WHERE indir LIKE :indirizzo
             AND civ = :civico LIMIT 1
         ';
     $indirizzo = "%{$indirizzo}%";
     $sth = DB::instance()->prepare($q);
     $sth->bindParam(':indirizzo', $indirizzo);
     $sth->bindParam(':civico', $civico, \PDO::PARAM_INT);
     $sth->execute();
     /** */
     $latLon = [0, 0];
     $row = $sth->fetch();
     if (isset($row['json'])) {
         $row = json_decode($row['json']);
         if (isset($row->coordinates[0])) {
             $row = $row->coordinates[0];
             $latLon = [$row[1], $row[0]];
         }
     }
     return $latLon;
 }