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


PHP Flight::select方法代碼示例

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


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

示例1: citypair

 function citypair($departureId, $arrivalId)
 {
     $routes = Flight::select('id', 'route', DB::raw('COUNT(route) AS count'))->whereDepartureId($departureId)->whereArrivalId($arrivalId)->where('route', '!=', '')->whereState(2)->groupBy('route')->orderBy('count', 'desc')->get();
     $departure = Airport::whereIcao($departureId)->first();
     $arrival = Airport::whereIcao($arrivalId)->first();
     $this->autoRender(compact('departure', 'arrival', 'routes', 'airports', 'departureId', 'arrivalId'), 'Routes for ' . $departureId . ' - ' . $arrivalId);
 }
開發者ID:T-SummerStudent,項目名稱:new,代碼行數:7,代碼來源:FlightController.php

示例2: index

    public function index()
    {
        $most_popular_routes = Timetable::select(DB::raw('*,
					COUNT(*) AS flights_per_week,
					least(origin_airport_id, destination_airport_id) as city1,
					greatest(origin_airport_id, destination_airport_id) as city2'))->with('origin', 'destination', 'airline')->groupBy(DB::raw('least(origin_airport_id, destination_airport_id)'))->groupBy(DB::raw('greatest(origin_airport_id, destination_airport_id)'))->orderBy('flights_per_week', 'DESC')->limit(20)->get();
        $most_km = Flight::select(DB::raw('airline_id, SUM(`distance`) AS overall_distance, COUNT(*) AS number_of_flights'))->with('airline')->where('accounted', '1')->groupBy('airline_id')->orderBy('overall_distance', 'DESC')->limit(20)->get();
        $longest_flights = Flight::select(DB::raw('*,
					COUNT(*) AS flights_per_week,
					least(origin_airport_id, destination_airport_id) as city1,
					greatest(origin_airport_id, destination_airport_id) as city2'))->with('origin', 'destination')->groupBy(DB::raw('least(origin_airport_id, destination_airport_id)'))->groupBy(DB::raw('greatest(origin_airport_id, destination_airport_id)'))->orderBy('distance', 'DESC')->limit(10)->get();
        $shortest_flights = Flight::select(DB::raw('*'))->with('origin', 'destination')->groupBy('origin_airport_id')->orderBy('distance', 'ASC')->limit(5)->get();
        return View::make('statistics/index', array('most_popular_routes' => $most_popular_routes, 'most_km' => $most_km, 'longest_flights' => $longest_flights, 'shortest_flights' => $shortest_flights));
        /*
        SELECT  `origin_airport_id` ,  `destination_airport_id` ,  `airline_id` , COUNT(  `origin_airport_id` )
        		FROM  `timetables`
        		GROUP BY  `origin_airport_id` ,  `destination_airport_id` ,  `airline_id`
        		ORDER BY COUNT(  `origin_airport_id` ) ASC
        */
    }
開發者ID:emtudo,項目名稱:airline-manager,代碼行數:20,代碼來源:StatisticsController.php


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