當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Driver::select方法代碼示例

本文整理匯總了PHP中Driver::select方法的典型用法代碼示例。如果您正苦於以下問題:PHP Driver::select方法的具體用法?PHP Driver::select怎麽用?PHP Driver::select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Driver的用法示例。


在下文中一共展示了Driver::select方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: function

Flight::route('GET /v1/main/driver', function () {
    $company = Flight::request()->query->company;
    try {
        if ($company) {
            $array = Driver::selectByCompany($company);
        } else {
            $array = Driver::selectAll();
        }
        Flight::ok($array);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('GET /v1/main/driver/@id', function ($id) {
    try {
        $object = Driver::select($id);
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('POST /v1/main/driver', function () {
    try {
        $object = Driver::insert();
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('PUT /v1/main/driver/@id', function ($id) {
    try {
開發者ID:rhalf,項目名稱:app_track,代碼行數:31,代碼來源:main.php

示例2: selectByCompany

 public static function selectByCompany($id)
 {
     $connection = Flight::dbMain();
     try {
         $sql = "SELECT * FROM vehicle WHERE company_id = :company;";
         $query = $connection->prepare($sql);
         $query->bindParam(':company', $id, PDO::PARAM_INT);
         $query->execute();
         $rows = $query->fetchAll(PDO::FETCH_ASSOC);
         $result = array();
         foreach ($rows as $row) {
             $vehicle = new Vehicle();
             $vehicle->Id = (int) $row['id'];
             $vehicle->DtCreated = $row['vehicle_dt_created'];
             $vehicle->DtSubscribed = $row['vehicle_dt_subscribed'];
             $vehicle->Plate = $row['vehicle_plate'];
             $vehicle->Name = $row['vehicle_name'];
             $vehicle->Model = $row['vehicle_model'];
             $vehicle->MaInitial = (int) $row['vehicle_ma_initial'];
             $vehicle->MaLimit = (int) $row['vehicle_ma_limit'];
             $vehicle->MaMaintenance = (int) $row['vehicle_ma_maintenance'];
             $vehicle->SpeedMax = (int) $row['vehicle_speed_max'];
             $vehicle->FuelMax = (int) $row['vehicle_fuel_max'];
             // $vehicle->Status = (int)$row['e_status_id'];
             // $vehicle->Driver =  $row['driver_id'] == null ? null : (int)$row['driver_id'];
             // $vehicle->Unit = $row['unit_id'] == null ? null : (int)$row['unit_id'];
             // $vehicle->Company = (int) $row['company_id'];
             // $vehicle->TrackeeType = (int) $row['e_trackee_type_id'];
             $vehicle->Status = (int) $row['e_status_id'];
             $vehicle->Driver = Driver::select($row['driver_id']);
             $vehicle->Unit = Unit::select($row['unit_id']);
             $vehicle->Company = Company::select($row['company_id']);
             $vehicle->TrackeeType = TrackeeType::select($row['e_trackee_type_id']);
             $vehicle->Status = Status::select($row['e_status_id']);
             array_push($result, $vehicle);
         }
         return $result;
     } catch (PDOException $pdoException) {
         throw $pdoException;
     } catch (Exception $exception) {
         throw $exception;
     } finally {
         $connection = null;
     }
 }
開發者ID:rhalf,項目名稱:app_track,代碼行數:45,代碼來源:vehicle.php


注:本文中的Driver::select方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。