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


PHP Place::getAll方法代码示例

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


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

示例1: session_start

<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/Place.php";
session_start();
if (empty($_SESSION['list_of_places'])) {
    $_SESSION['list_of_places'] = 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('places.html.twig', array('places' => Place::getAll()));
});
$app->post("/places", function () use($app) {
    $place = new Place($_POST['city']);
    $place->save();
    return $app['twig']->render('create_place.html.twig', array('newplace' => $task));
});
return $app;
开发者ID:aftondowney,项目名称:places,代码行数:19,代码来源:app.php

示例2: function

// routes
$app->get("/", function () use($app) {
    return $app['twig']->render('home.html.twig', array('places' => Place::getAll()));
});
$app->post('/add_place', function () use($app) {
    $place = new Place($_POST['city'], $_POST['country'], $_POST['year'], $_POST['image_src']);
    $place->save();
    return $app['twig']->render('home.html.twig', array('places' => Place::getAll(), 'message' => array("text" => "Sounds like a fun trip!", 'type' => 'info')));
});
$app->post('/delete_all', function () use($app) {
    Place::deleteAll();
    return $app['twig']->render('home.html.twig', array('places' => Place::getAll(), 'message' => array("text" => "Time to book a trip!", 'type' => 'info')));
});
$app->post('/delete_one', function () use($app) {
    $name_of_place = $_POST['delete_one'];
    $found = false;
    foreach ($_SESSION['list_of_places'] as $key => $place) {
        if ($place->getCity() == $name_of_place) {
            $found = true;
            $key_to_delete = $key;
            break;
        }
    }
    $place_to_delete = $_SESSION['list_of_places'][$key];
    $place_to_delete->delete();
    return $app['twig']->render('home.html.twig', array('places' => Place::getAll(), 'message' => array("text" => $name_of_place . " was deleted!", 'type' => 'danger')));
});
$app->get('/show_form', function () use($app) {
    return $app['twig']->render('home.html.twig', array('places' => Place::getAll(), 'form' => true));
});
return $app;
开发者ID:joekarasek,项目名称:epicodus-php-places,代码行数:31,代码来源:app.php

示例3: session_start

<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/Place.php";
//SESSION - Stores Cookies
session_start();
if (empty($_SESSION['list_of_cities'])) {
    $_SESSION['list_of_cities'] = array();
}
$app = new Silex\Application();
//Twig Path
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
//Route and Controller
$app->get("/", function () use($app) {
    $all_cities = Place::getAll();
    return $app['twig']->render('city.html.twig', array('cities' => $all_cities));
});
/*  $app->get("/", function() use ($app) {

        $all_times = Place::getAll();

        return $app['twig']->render('city.html.twig', array('times' => $all_times));

      }); */
//cities POST
$app->post("/city", function () use($app) {
    $city = new Place($_POST['cityName'], $_POST['lengthOfTime'], $_POST['reasonOfVisit'], $_POST['imagePath']);
    $city->save();
    return $app['twig']->render('create_city.html.twig', array('newcity' => $city));
});
//cities POST delete
开发者ID:kevintokheim,项目名称:Places_You_Been,代码行数:31,代码来源:app.php

示例4: testDeleteAll

 function testDeleteAll()
 {
     //Arrange
     $place_name = "Director Park";
     $address = "SW Park Ave";
     $latitude = 45.518672;
     $longitude = -122.681211;
     $id = 1;
     $test_place = new Place($place_name, $address, $latitude, $longitude, $id);
     $test_place->save();
     //Act
     Place::deleteAll();
     $result = Place::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
开发者ID:juliocesardiaz,项目名称:Face2Face,代码行数:16,代码来源:PlaceTest.php

示例5: generateLocation

 static function generateLocation()
 {
     $places = Place::getAll();
     $number_of_places = count($places);
     $random_number = rand(0, $number_of_places - 1);
     $random_location = $places[$random_number];
     return $random_location;
 }
开发者ID:juliocesardiaz,项目名称:Face2Face,代码行数:8,代码来源:Place.php


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