当前位置: 首页>>代码示例>>PHP>>正文


PHP Car::getAll方法代码示例

本文整理汇总了PHP中Car::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Car::getAll方法的具体用法?PHP Car::getAll怎么用?PHP Car::getAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Car的用法示例。


在下文中一共展示了Car::getAll方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Car

$ford = new Car("2011 Ford F450", 55995, 14241, "images/ford.jpg");
$lexus = new Car("2013 Lexus RX 350", 44700, 20000, "images/lexus.jpg");
$mercedes = new Car("Mercedes Benz CLS550", 39900, 37979, "images/mercedes.jpg");
if (empty($_SESSION['list_of_cars'])) {
    $_SESSION['list_of_cars'] = array($porsche, $ford, $lexus, $mercedes);
}
$app = new Silex\Application();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
/* CAR_FORM.HTML.TWIG - Home route */
$app->get("/", function () use($app) {
    return $app['twig']->render('car_form.html.twig', array('cars' => Car::getAll()));
});
/* END CAR_FORM.HTML.TWIG */
/* START VIEW_CAR.HTML.TWIG */
$app->get("/view_car", function () use($app) {
    $cars = Car::getAll();
    $cars_matching_search = array();
    foreach ($cars as $car) {
        if ($car->worthBuying($_GET["price"]) && $car->worthBuying($_GET["miles"])) {
            array_push($cars_matching_search, $car);
        }
    }
    return $app['twig']->render('view_car.html.twig', array('cars' => $cars_matching_search));
});
/* END VIEW_CAR.HTML.TWIG */
/* BEGIN SELL_CAR.HTML.TWIG */
$app->get("/sell_car", function () use($app) {
    return $app['twig']->render('sell_car.html.twig');
});
$app->post("/car_added", function () use($app) {
    $car = new Car($_POST['make'], $_POST['price'], $_POST['miles'], $_POST['photo']);
开发者ID:JordanNavratil,项目名称:Dealership_twig,代码行数:31,代码来源:app.php

示例2: array

$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
// $app['debug'] = true;
// Home Page - Search
$app->get("/", function () use($app) {
    return $app['twig']->render('cars.html.twig');
});
// Home Page - Results/Post
$app->post("/New_Car", function () use($app) {
    $car = new Car($_POST['make_model'], $_POST['price'], $_POST['miles'], $_POST['picture']);
    $car->save();
    return $app['twig']->render('New_Car.html.twig', array('newcar' => $car));
});
// Your Cars - Results Page
$app->get('/your_cars', function () use($app) {
    var_dump(Car::getAll());
    return $app['twig']->render('your_cars.html.twig', array('cars' => Car::getAll()));
});
/* Create objects for the Car class, and store the worth buying array while
   routing the results to cars_matching_search.html.twig */
$app->get("/car_results", function () use($app) {
    $first_car = new Car("2014 Porsche 911", 7864, 114991, "images/porsche.jpg");
    $second_car = new Car("2011 Ford F450", 14000, 55995, "images/ford.jpeg");
    $third_car = new Car("2013 Lexus RX 350", 20000, 44700, "images/lexus.jpg");
    $fourth_car = new Car("Mercedes Benz CLS550", 37979, 39900, "images/mercedes.jpg");
    $cars = array($first_car, $second_car, $third_car, $fourth_car);
    $cars_matching_search = array();
    foreach ($cars as $car) {
        if ($car->worthBuying($_GET["price"], $_GET["miles"])) {
            array_push($cars_matching_search, $car);
        }
    }
开发者ID:kellimargaret,项目名称:Car-Dealership,代码行数:31,代码来源:app.php

示例3: testHelperMethods

 public function testHelperMethods()
 {
     $cars = Car::getAll();
     $this->assertEquals('cars', Car::getTablename());
     $this->assertEquals('id', Car::getUniqueId());
 }
开发者ID:johnkariuki,项目名称:checkpoint-two-potato-orm,代码行数:6,代码来源:PotatoModelTest.php

示例4: array

    $_SESSION['cars_list'] = array();
}
$app = new Silex\Application();
// $app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('car_form.html.twig');
});
$app->post("/show", function () use($app) {
    $car = new Car($_POST['model'], $_POST['price'], $_POST['image'], $_POST['miles']);
    $car->save();
    return $app['twig']->render('car_dealership.html.twig', array('cars' => Car::getAll()));
});
$app->get("/list", function () use($app) {
    return $app['twig']->render('car_dealership.html.twig', array('cars' => Car::getAll()));
});
$app->get("car_search", function () use($app) {
    $cars = Car::getAll();
    $cars_matching_search = array();
    foreach ($cars as $car) {
        if ($car->worthBuying($_GET["price"]) && $car->maxMileage($_GET["mileage"])) {
            array_push($cars_matching_search, $car);
        }
    }
    return $app['twig']->render('car_search.html.twig', array('cars' => $cars_matching_search));
});
$app->post("/clear", function () use($app) {
    Car::reset();
    return $app['twig']->render('car_dealership.html.twig', array('cars' => Car::getAll()));
});
return $app;
开发者ID:adamrr724,项目名称:Car-PHP,代码行数:31,代码来源:app.php

示例5: array

$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
//Route and Controller
$app->get('/', function () use($app) {
    $all_cars = Car::getAll();
    return $app['twig']->render('cars.html.twig', array('cars' => $all_cars));
});
//Cars Post
$app->post('/cars', function () use($app) {
    $car = new Car($_POST['carModel'], $_POST['carPrice'], $_POST['carMiles'], $_POST['carPhoto']);
    $car->save();
    return $app['twig']->render('create_cars.html.twig', array('newcar' => $car));
});
//Cars Post Delete
$app->post("/delete_cars", function () use($app) {
    Car::deleteAll();
    return $app['twig']->render('delete_cars.html.twig');
});
//car search
$app->get("/car_results", function () use($app) {
    $search = Car::getAll();
    $cars_matching_search = array();
    foreach ($search as $result) {
        if ($result->getPrice() < $_GET["price"]) {
            if ($result->getMiles() < $_GET["miles"]) {
                array_push($cars_matching_search, $result);
            }
        }
    }
    return $app['twig']->render('car_results.html.twig', array('search_data' => $cars_matching_search));
});
return $app;
开发者ID:alexMcosta,项目名称:cars_2.0,代码行数:31,代码来源:app.php

示例6: session_start

<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/Car.php";
session_start();
if (empty($_SESSION['car_list'])) {
    $_SESSION['car_list'] = array();
}
$app = new Silex\Application();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('add_car.html.twig');
});
$app->post("/confirmation", function () use($app) {
    $car = new Car($_POST['make_model'], $_POST['price'], $_POST['miles']);
    $car->save();
    return $app['twig']->render('confirmation.html.twig', array('newcar' => $car));
});
$app->get("/car_list", function () use($app) {
    return $app['twig']->render('car_list.html.twig', array('cars' => Car::getAll()));
});
$app->get("/search_results", function () use($app) {
    return $app['twig']->render('search_results.html.twig', array('cars' => Car::getAll(), 'max_price' => $_GET['price']));
});
$app->post("/clear_list", function () use($app) {
    return $app['twig']->render('car_list.html.twig', array('cars' => Car::deleteAll()));
});
return $app;
开发者ID:jcfix,项目名称:car-dealership,代码行数:28,代码来源:app.php

示例7: session_start

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/car.php";
session_start();
if (empty($_SESSION['list_of_cars'])) {
    $_SESSION['list_of_cars'] = array();
}
$app = new Silex\Application();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app['debug'] = true;
$app->get("/", function () use($app) {
    return $app['twig']->render('home.html.twig', array('cars' => Car::getAll()));
});
$app->get("/car_output", function () use($app) {
    $cars_matching_search = array();
    foreach (Car::getAll() as $car) {
        if ($car->worthBuying($_GET["price"], $_GET["mileage"])) {
            array_push($cars_matching_search, $car);
        }
    }
    return $app['twig']->render('caroutput.html.twig', array('cars' => $cars_matching_search));
});
$app->get("/newlisting", function () use($app) {
    return $app['twig']->render('newlisting.html.twig');
});
$app->post("/listingresult", function () use($app) {
    $car = new Car($_POST['make_model'], $_POST['price'], $_POST['mileage']);
    $cars_listed = array($car);
    $car->save();
    return $app['twig']->render('listingresult.html.twig', array('newcars' => $cars_listed));
});
开发者ID:blakerscott,项目名称:dealership-twig,代码行数:30,代码来源:app.php

示例8: Car

    $firstCar = new Car("Tesla X", 100000, 0, "pictures/tesla.jpg");
    $secondCar = new Car("Honda Accord", 10000, 50000, "pictures/honda.jpg");
    $thirdCar = new Car("Ferrari Enzo", 350000, 15000, "pictures/ferrari-enzo.jpg");
    $fourthCar = new Car("Toyota Corolla", 6000, 100000, "pictures/toyota-corolla.jpg");
    $fifthCar = new Car("Mitsubishi Lancer", 20000, 100, "pictures/mitsubishi-lancer.jpg");
    $allCars = array($firstCar, $secondCar, $thirdCar, $fourthCar, $fifthCar);
    $_SESSION['list_of_cars'] = $allCars;
}
$app = new Silex\Application();
$app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('dealership_search.html.twig');
});
$app->get("/view_cars", function () use($app) {
    $totalCars = Car::getAll();
    $matchingCars = array();
    $max_price = $_GET["max_price"];
    $max_miles = $_GET["max_mileage"];
    foreach ($totalCars as $car) {
        $price = $car->getPrice();
        $mileage = $car->getMiles();
        if ($price <= $max_price && $mileage <= $max_miles) {
            array_push($matchingCars, $car);
        }
    }
    return $app['twig']->render('results.html.twig', array('matchedCars' => $matchingCars));
});
$app->get("/car_form", function () use($app) {
    return $app['twig']->render('car_form.html.twig');
});
开发者ID:juliocesardiaz,项目名称:Dealership,代码行数:31,代码来源:app.php


注:本文中的Car::getAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。