當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Restaurant::getAll方法代碼示例

本文整理匯總了PHP中Restaurant::getAll方法的典型用法代碼示例。如果您正苦於以下問題:PHP Restaurant::getAll方法的具體用法?PHP Restaurant::getAll怎麽用?PHP Restaurant::getAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Restaurant的用法示例。


在下文中一共展示了Restaurant::getAll方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: delete

 function delete()
 {
     $restaurants = Restaurant::getAll();
     foreach ($restaurants as $restaurant) {
         if ($restaurant->getCuisineId() == $this->getId()) {
             $restaurant->delete();
         }
     }
     $GLOBALS['DB']->exec("DELETE FROM cuisines WHERE id = {$this->getId()};");
 }
開發者ID:juliocesardiaz,項目名稱:Best-restaurants,代碼行數:10,代碼來源:Cuisine.php

示例2: find

 static function find($restaurant_id)
 {
     $found_restaurant = null;
     $restaurants = Restaurant::getAll();
     foreach ($restaurants as $restaurant) {
         if ($restaurant->getId() == $restaurant_id) {
             $found_restaurant = $restaurant;
         }
     }
     return $found_restaurant;
 }
開發者ID:ben-pritchard,項目名稱:allergen_avoider,代碼行數:11,代碼來源:Restaurant.php

示例3: test_getAll

 function test_getAll()
 {
     //Arrange
     $restaurant_name = "Antoons";
     $cuisine_type = 1;
     $restaurant_phone = "4128675309";
     $restaurant_address = "123 Atwood St";
     $test_Restaurant = new Restaurant($restaurant_name, $cuisine_type, $restaurant_phone, $restaurant_address);
     $test_Restaurant->save();
     $restaurant_name = "Spankys";
     $cuisine_type = 2;
     $restaurant_phone = "8015715713";
     $restaurant_address = "379 E 3333 S";
     $test_next_Restaurant = new Restaurant($restaurant_name, $cuisine_type, $restaurant_phone, $restaurant_address);
     $test_next_Restaurant->save();
     //Act
     $result = Restaurant::getAll();
     //Assert
     $this->assertEquals([$test_Restaurant, $test_next_Restaurant], $result);
 }
開發者ID:kellimargaret,項目名稱:restaurants,代碼行數:20,代碼來源:RestaurantTest.php

示例4: testDelete

 function testDelete()
 {
     //Arrange
     $restaurant_name = "McDonalds";
     $id = null;
     $test_restaurant = new Restaurant($restaurant_name, $id);
     $test_restaurant->save();
     $restaurant_name2 = "Joes Burgers";
     $test_restaurant2 = new Restaurant($restaurant_name2, $id);
     $test_restaurant2->save();
     //Act
     $test_restaurant->deleteOne();
     //Assert
     $this->assertEquals([$test_restaurant2], Restaurant::getAll());
 }
開發者ID:kennygrage,項目名稱:epicRestaurant,代碼行數:15,代碼來源:RestaurantTest.php

示例5: test_cuisine_delete

 function test_cuisine_delete()
 {
     $style = "Thai";
     $test_cuisine = new Cuisine($style);
     $test_cuisine->save();
     $style2 = "burgers";
     $test_cuisine2 = new Cuisine($style2);
     $test_cuisine2->save();
     $name = "Pok Pok";
     $category_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($name, $category_id);
     $test_restaurant->save();
     $name2 = "Dicks";
     $category_id2 = $test_cuisine2->getId();
     $test_restaurant2 = new Restaurant($name2, $category_id2);
     $test_restaurant2->save();
     //Act
     $test_cuisine->delete();
     //Assert
     $this->assertEquals([$test_restaurant2], Restaurant::getAll());
 }
開發者ID:umamiMike,項目名稱:restaurantApp,代碼行數:21,代碼來源:CuisineTest.php

示例6: test_delete

 function test_delete()
 {
     $name = "Asian";
     $id = null;
     $test_cuisine = new Cuisine($name, $id);
     $test_cuisine->save();
     $restaurant_name = "The Golden Duck";
     $location = "898 SW 5th Ave, Portland, OR";
     $description = "A Chill Asian experince";
     $price = "\$\$";
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($restaurant_name, $location, $description, $price, $cuisine_id);
     $test_restaurant->save();
     $restaurant_name2 = "The Red Dragon";
     $location2 = "899 SW 5th Ave, Portland, OR";
     $description2 = "A Intense Asian experince";
     $price2 = "\$\$\$";
     $cuisine_id2 = $test_cuisine->getId();
     $test_restaurant2 = new Restaurant($restaurant_name2, $location2, $description2, $price2, $cuisine_id2);
     $test_restaurant2->save();
     $test_restaurant->delete();
     $result = Restaurant::getAll();
     $this->assertEquals($test_restaurant2, $result[0]);
 }
開發者ID:juliocesardiaz,項目名稱:Best-restaurants,代碼行數:24,代碼來源:RestaurantTest.php

示例7: test_deleteCuisineRestaurants

 function test_deleteCuisineRestaurants()
 {
     $type = "Mexican";
     $id = null;
     $test_Cuisine = new Cuisine($type, $id);
     $test_Cuisine->save();
     $name = "Por Que No";
     $phone = "555-555-5555";
     $address = "123 ABC street";
     $website = "http://www.porqueno.com";
     $cuisine_id = $test_Cuisine->getId();
     $test_Restaurant = new Restaurant($name, $id, $phone, $address, $website, $cuisine_id);
     $test_Restaurant->save();
     $test_Cuisine->delete_cuisine();
     $this->assertEquals([], Restaurant::getAll());
 }
開發者ID:jeffaustin81,項目名稱:Restaurants,代碼行數:16,代碼來源:CuisineTest.php

示例8: testDeleteCuisineRestaurants

 function testDeleteCuisineRestaurants()
 {
     //Arrange
     $name = "Italian";
     $id = null;
     $test_cuisine = new Cuisine($name, $id);
     $test_cuisine->save();
     $name = "Piazza Italia";
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($name, $id, $cuisine_id, $rating);
     $test_restaurant->save();
     //Act
     $test_cuisine->delete();
     //Assert
     $this->assertEquals([], Restaurant::getAll());
 }
開發者ID:anniehoogendoorn,項目名稱:BestRestaurants,代碼行數:16,代碼來源:CuisineTest.php

示例9: test_DeleteCuisineRestaurants

 function test_DeleteCuisineRestaurants()
 {
     //Arrange
     //cuisine
     $name = "Japanese";
     $id = null;
     $test_cuisine = new Cuisine($name, $id);
     $test_cuisine->save();
     //restaurant
     $name = "Good Fortune";
     $cuisine_id = $test_cuisine->getId();
     $description = "very tasty.";
     $address = "1111 SW 11th Ave";
     $test_restaurant = new Restaurant($name, $id, $cuisine_id, $description, $address);
     $test_restaurant->save();
     //Act
     $test_cuisine->delete();
     //Assert
     $this->assertEquals([], Restaurant::getAll());
 }
開發者ID:Camolot,項目名稱:restaurants,代碼行數:20,代碼來源:CuisineTest.php

示例10: function

});
//Save a new restaurant:
$app->post("/restaurants", function () use($app) {
    $name = $_POST['name'];
    $phone = $_POST['phone'];
    $price = $_POST['price'];
    $cuisine_id = $_POST['cuisine_id'];
    $restaurant = new Restaurant($name, $phone, $price, $cuisine_id);
    $restaurant->save();
    $cuisine = Cuisine::find($cuisine_id);
    return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'restaurants' => $cuisine->getRestaurants()));
});
//View list of restaurants after save:
$app->get("/restaurants", function () use($app) {
    $cuisine = Cuisine::find($cuisine_id);
    return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'restaurants' => Restaurant::getAll()));
});
//Page for editing a cuisine:
$app->get("/cuisines/{id}/edit", function ($id) use($app) {
    $cuisine = Cuisine::find($id);
    return $app['twig']->render('cuisine_edit.html.twig', array('cuisine' => $cuisine));
});
//Update a cuisine form:
$app->patch("/cuisines/{id}", function ($id) use($app) {
    $type = $_POST['type'];
    $cuisine = Cuisine::find($id);
    $cuisine->update($type);
    return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'restaurants' => $cuisine->getRestaurants()));
});
//Edit a restaurant page:
$app->get("/restaurants/{id}/edit", function ($id) use($app) {
開發者ID:kylepratuch,項目名稱:restaurants_by_cuisine,代碼行數:31,代碼來源:app.php

示例11: test_deleteAll

 function test_deleteAll()
 {
     //Arrange
     $name = "Italian";
     $id = null;
     $test_cuisine = new Cuisine($name, $id);
     $test_cuisine->save();
     $name = "Piazza Italia";
     $rating = 1;
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($name, $id, $cuisine_id, $rating);
     $test_restaurant->save();
     $name2 = "Ristorante Roma";
     $rating = 1;
     $test_restaurant2 = new Restaurant($name2, $id, $cuisine_id, $rating);
     $test_restaurant2->save();
     //Act
     Restaurant::deleteAll();
     //Assert
     $result = Restaurant::getAll();
     $this->assertEquals([], $result);
 }
開發者ID:anniehoogendoorn,項目名稱:BestRestaurants,代碼行數:22,代碼來源:RestaurantTest.php

示例12: find_restaurant

 static function find_restaurant($search_id)
 {
     $found_restaurant = array();
     $restaurants = Restaurant::getAll();
     foreach ($restaurants as $restaurant) {
         $restaurant_id = $restaurant->getId();
         if ($restaurant_id == $search_id) {
             $found_restaurant = array($restaurant->getName(), $restaurant_id, $restaurant->getPhone(), $restaurant->getAddress(), $restaurant->getWebsite(), $restaurant->getCategoryId());
         }
     }
     return $found_restaurant;
 }
開發者ID:jeffaustin81,項目名稱:Restaurants,代碼行數:12,代碼來源:Restaurant.php

示例13: testDeleteAll

 function testDeleteAll()
 {
     //Arrange
     $type = "Italian";
     $id = null;
     $test_cuisine = new Cuisine($type, $id);
     $test_cuisine->save();
     $name = "City Chinese";
     $description = "OK Chinese food";
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($description, $id, $cuisine_id, $name);
     $test_restaurant->save();
     $name2 = "City Mexican";
     $description2 = "OK Mexican food";
     $test_restaurant2 = new Restaurant($description2, $id, $cuisine_id, $name2);
     $test_restaurant2->save();
     //Assert
     Restaurant::deleteAll();
     //Assert
     $result = Restaurant::getAll();
     $this->assertEquals([], $result);
 }
開發者ID:r-hills,項目名稱:Restaurant_Reviews,代碼行數:22,代碼來源:RestaurantTest.php

示例14: test_Delete

 function test_Delete()
 {
     //Arrange
     $name = "American";
     $id = null;
     $test_cuisine = new Cuisine($name, $id);
     $test_cuisine->save();
     $restaurant_name = "VQ";
     $phone = '5032277342';
     $address = "1220 SW 1st Ave, Portland, OR 97204";
     $website = "http://www.veritablequandary.com/";
     $cuisine_id = $test_cuisine->getId();
     $test_restaurant = new Restaurant($restaurant_name, $phone, $address, $website, $cuisine_id);
     $test_restaurant->save();
     $restaurant_name2 = "Hot Lips Pizza";
     $phone2 = '5035952342';
     $address2 = "721 NW 9th Ave #150, Portland, OR 97209";
     $website2 = "http://hotlipspizza.com/";
     $test_restaurant2 = new Restaurant($restaurant_name2, $phone2, $address2, $website2, $cuisine_id);
     $test_restaurant2->save();
     //Act
     $test_restaurant->delete();
     //Assert
     $this->assertEquals([$test_restaurant2], Restaurant::getAll());
 }
開發者ID:alexdbrown,項目名稱:best_restaurant,代碼行數:25,代碼來源:RestaurantTest.php

示例15: findRestaurantName

 static function findRestaurantName($search_restaurant)
 {
     $found_restaurants = array();
     $restaurants = Restaurant::getAll();
     foreach ($restaurants as $restaurant) {
         $restaurant_name = $restaurant->getName();
         if (strpos(strtolower($restaurant_name), strtolower($search_restaurant)) !== false) {
             array_push($found_restaurants, $restaurant);
         }
     }
     return $found_restaurants;
 }
開發者ID:nathanhwyoung,項目名稱:restaurant,代碼行數:12,代碼來源:Restaurant.php


注:本文中的Restaurant::getAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。