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


PHP Car::deleteAll方法代码示例

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


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

示例1: print_r

    //in order to get the default value to be applied, i had to remove "$POST['miles']" entirely. so, it seems as if there's nothing to detect whether it is a value of zero or not, and what to do if that is not okay. check
    $new_car->save();
    echo "<pre>";
    print_r($new_car);
    echo "</pre><br>";
    return $app['twig']->render('list_car.html.twig', array('list_car' => $new_car));
});
$app->get("/car_lot", function () use($app) {
    return $app['twig']->render('car_lot.html.twig', array('autos' => Car::getAll()));
});
$app->get("/match_cars", function () use($app) {
    $cars = Car::getAll();
    $cars_matching_search = array();
    foreach ($cars as $car) {
        if ($car->worthBuying($_GET['max_price'], $_GET['max_miles'])) {
            array_push($cars_matching_search, $car);
        }
    }
    echo "<pre>";
    print_r($cars);
    echo "</pre><br>";
    echo "<pre>";
    print_r($cars_matching_search);
    echo "</pre><br>";
    return $app['twig']->render('match_cars.html.twig', array('cars_matching_search' => $cars_matching_search));
});
$app->post("/delete_cars", function () use($app) {
    Car::deleteAll();
    return $app['twig']->render('delete_cars.html.twig');
});
return $app;
开发者ID:jmalo34,项目名称:car,代码行数:31,代码来源:app.php

示例2: 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


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