public static function getRoutes(Agency $agency, $version = 0) { /** * @var DB */ $dbObj = DBPool::getInstance(); $version = $version == 0 ? TableUpdate::getVersion() : $version; $dbObj->bindParams(array($agency->getId(), $version)); $routes = $dbObj->get_results("SELECT * FROM route WHERE agency_id=?\n AND version = ? ORDER BY position"); if ($dbObj->num_rows > 0) { $routeArray = array(); foreach ($routes as $r) { $routeObj = new Route(); $routeObj->setId($r->id); $routeObj->setAgency($agency); $routeObj->setTag($r->tag); $routeObj->setColor($r->color); $routeObj->setTitle($r->title); $routeObj->setShortTitle($r->short_title); $routeObj->setLatMin($r->lat_min); $routeObj->setLatMax($r->lat_max); $routeObj->setLonMin($r->lon_min); $routeObj->setLonMax($r->lon_max); $routeObj->setVehicleType($r->vehicle_type); $routeObj->setPosition($r->position); $routeArray[$r->tag] = $routeObj; } return $routeArray; } else { //TODO: Don't use a generic exception throw new Exception("No data available - Route::getRoutes"); } }