本文整理汇总了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);
}
示例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
*/
}