示例#1
0
 public static function select($id)
 {
     $connection = Flight::dbMain();
     try {
         $sql = "SELECT * FROM company_address WHERE id = :id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         if ($query->rowCount() < 1) {
             return null;
         }
         $row = $query->fetch(PDO::FETCH_ASSOC);
         $address = new Address();
         $address->Id = (int) $row['id'];
         $address->Name = $row['address_name'];
         $address->Full = $row['address_full'];
         $address->Coordinate = new Coordinate((double) $row['address_latitude'], (double) $row['address_longitude']);
         $address->Country = $row['address_country'];
         $address->City = $row['address_city'];
         $address->Area = $row['address_area'];
         $address->Nation = Nation::select($row['e_nation_id']);
         return $address;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
示例#2
0
 public static function select($id)
 {
     $connection = Flight::dbMain();
     try {
         $sql = "SELECT * FROM e_sim_vendor WHERE id = :id;";
         $query = $connection->prepare($sql);
         $query->bindParam(':id', $id, PDO::PARAM_INT);
         $query->execute();
         if ($query->rowCount() < 1) {
             return null;
         }
         $row = $query->fetch(PDO::FETCH_ASSOC);
         $simVendor = new SimVendor();
         $simVendor->Id = (int) $row['id'];
         $simVendor->Name = $row['sim_vendor_name'];
         $simVendor->Desc = $row['sim_vendor_desc'];
         $simVendor->Nation = Nation::select($row['e_nation_id']);
         return $simVendor;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
示例#3
0
文件: main.php 项目: rhalf/app_track
    }
});
//=============================================================================
//Nation
//=============================================================================
Flight::route('GET /v1/main/nation', function () {
    try {
        $array = Nation::selectAll();
        Flight::ok($array);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('GET /v1/main/nation/@id', function ($id) {
    try {
        $object = Nation::select($id);
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('POST /v1/main/nation', function () {
    try {
        $object = Nation::insert();
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('PUT /v1/main/nation/@id', function ($id) {
    try {