本文整理汇总了PHP中Restaurant::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Restaurant::save方法的具体用法?PHP Restaurant::save怎么用?PHP Restaurant::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Restaurant
的用法示例。
在下文中一共展示了Restaurant::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Cuisine
function test_GetRestaurants()
{
//Arrange
$name = "Drinks";
$id = null;
$test_cuisine = new Cuisine($name, $id);
$test_cuisine->save();
$restaurant = "Aalto";
$address = "123 Belmont";
$phone = "123-456-7890";
$cuisine_id = $test_cuisine->getId();
$id = 1;
$test_restaurant = new Restaurant($restaurant, $address, $phone, $cuisine_id, $id);
$test_restaurant->save();
$restaurant2 = "Aalto";
$address2 = "123 Belmont";
$phone2 = "123-456-7890";
$cuisine_id2 = $test_cuisine->getId();
$id = 2;
$test_restaurant2 = new Restaurant($restaurant, $address, $phone, $cuisine_id, $id);
$test_restaurant2->save();
//Act
$result = $test_cuisine->getRestaurants();
//Assert
$this->assertEquals([$test_restaurant, $test_restaurant2], $result);
}
示例2: Cuisine
function fest_allRestaurantsInCuisine()
{
//Arrange
$cuisine = "Pizza";
$test_cuisine = new Cuisine($cuisine);
$test_cuisine->save();
$cuisine = "Burgers";
$test_cuisine2 = new Cuisine($cuisine);
$test_cuisine2->save();
$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();
$restaurant_name = "Dave & Busters";
$cuisine_type = 1;
$restaurant_phone = "44444444";
$restaurant_address = "HELL";
$test_third_restaurant = new Restaurant($restaurant_name, $cuisine_type, $restaurant_phone, $restaurant_address);
$test_third_restaurant->save();
//Act
$result = Cuisine::getRestaurants();
//Assert
$this->assertEquals([$test_Restaurant, $test_third_restaurant], $result);
}
示例3: Restaurant
function test_find()
{
//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();
//Act
$result = Restaurant::find($test_Restaurant->getId());
//Assert
$this->assertEquals($test_Restaurant, $result);
}
示例4: actionAdd_restaurant
public function actionAdd_restaurant()
{
$restaurant = new Restaurant();
$restaurant->style = $_POST['style'];
$restaurant->content = $_POST['content'];
$restaurant->company = $_POST['company'];
if (isset($_POST['source'])) {
$restaurant->source = $_POST['source'];
}
if (isset($_POST['thumb'])) {
$restaurant->thumb = $_POST['thumb'];
}
$restaurant->boat = $_POST['boat'];
$restaurant->save();
//$this->redirect(Yii::app()->request->urlReferrer);
echo 1;
// echo CJSON::encode(array('title'=>$_POST['title'], 'area'=>$_POST['area'], 'port'=>$_POST['port']));//Yii 的方法将数组处理成json数据
}
示例5: ActionAddRestaurant
/**
* 添加餐厅
*/
public function ActionAddRestaurant()
{
$restaurant_model = new Restaurant();
if (isset($_POST['Restaurant'])) {
// 填充模型
$restaurant_model->attributes = $_POST['Restaurant'];
// 执行添加
if ($restaurant_model->save()) {
// 添加操作日志 [S]
$log = Yii::app()->user->name . '于 ' . date('Y-m-d H:i:s', time()) . ' 添加了一个名为 【' . $_POST['Restaurant']['RestaurantName'] . '】 的餐厅';
OperationLogManage::AddOperationLog($log);
// 添加日志
// 添加操作日志 [E]
Yii::app()->user->setFlash('save_sign', '添加成功');
$this->redirect(Yii::app()->createUrl('Restaurant/ListRestaurant'));
} else {
Yii::app()->user->setFlash('save_sign', '添加失败');
$this->renderPartial('add_restaurant', array('restaurant_model' => $restaurant_model));
}
} else {
// 跳转至添加页
$this->renderPartial('add_restaurant', array('restaurant_model' => $restaurant_model));
}
}
示例6: testUpdateAnswer
function testUpdateAnswer()
{
//Arrange
//We need a User and a User saved
//Arrange
//We need a User and a User saved
$user = "HIST100";
$password = "Abeer";
$id = null;
$vegie = 0;
$admin = 1;
$test_User = new User($user, $password, $vegie, $admin, $id);
$test_User->save();
$name = "Little Big Burger";
$address = "123 NW 23rd Ave.";
$phone = "971-289-8000";
$price = 1;
$vegie = 0;
$opentime = 00;
$closetime = 2100;
$id = 1;
$test_restaurant = new Restaurant($name, $address, $phone, $price, $vegie, $opentime, $closetime, $id);
$test_restaurant->save();
$answer = 0;
$restaurant_id = 1;
$user_id = 1;
$id2 = 1;
$test_response = new Response($answer, $restaurant_id, $user_id, $id2);
$test_response->save();
$test_User->addAnswer($test_User->getId(), $test_restaurant->getId(), $test_response->getAnswer());
$test_User->updateAnswer(2, 1);
$this->assertEquals($test_User->getDisLikes(), [$test_restaurant]);
}
示例7: Cuisine
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());
}
示例8: array
return $app['twig']->render('index.html.twig');
#, array('options' => Option::getAll()));
});
$app->post('/options', function () use($app) {
$suitable_option_names = $_POST["option_names"];
$suitable_option_ids = Option::getIdsFromNames($suitable_option_names);
$options = Option::getObjects($suitable_option_ids);
$suitable_restaurants = Restaurant::suitableRestaurants($suitable_option_ids);
return $app['twig']->render('results.html.twig', array('suitable_restaurants' => $suitable_restaurants, 'options' => $options));
});
$app->get('/admin', function () use($app) {
return $app['twig']->render('admin.html.twig', array('restaurants' => Restaurant::getAll(), 'options' => Option::getAll()));
});
$app->post('/add_restaurants', function () use($app) {
$restaurant_name = new Restaurant($_POST['restaurant_name']);
$restaurant_name->save();
return $app['twig']->render('admin.html.twig', array('restaurants' => Restaurant::getAll(), 'options' => Option::getAll()));
});
$app->post('/add_options', function () use($app) {
$option_name = new Option($_POST['option_name']);
$option_name->save();
return $app['twig']->render('admin.html.twig', array('restaurants' => Restaurant::getAll(), 'options' => Option::getAll()));
});
$app->post('/add_restaurant_options', function () use($app) {
$restaurant = Restaurant::find($_POST['restaurant_id']);
$option = Option::find($_POST['option_id']);
$restaurant->addOption($option);
return $app['twig']->render('restaurant.html.twig', array('restaurant' => $restaurant, 'restaurant_options' => $restaurant->getOptions(), 'all_options' => Option::getAll()));
});
$app->post('/add_option_restaurants', function () use($app) {
$option = Option::find($_POST['option_id']);
示例9: testDelete
function testDelete()
{
//Arrange
$name = "Pizza Party";
$phone_number = "123-456-7890";
$address = "1234 Pepperoni Lane";
$id = null;
$cuisine_id = 4;
$test_restaurant = new Restaurant($name, $phone_number, $address, $id, $cuisine_id);
$restaurant_id = $test_restaurant->getId();
$test_restaurant->save();
$name2 = "Burger Bash ";
$test_restaurant2 = new Restaurant($name2, $phone_number, $address, $id, $cuisine_id);
$test_restaurant2->save();
//Act
$test_restaurant->delete();
//Assert
$this->assertEquals([$test_restaurant2], Restaurant::getAll());
}
示例10: Cuisine
function test_DeleteCuisineRestaurants()
{
//Arrange
$id = null;
$cuisine_type = "Brazilian";
$test_cuisine_type = new Cuisine($id, $cuisine_type);
$name = "Peles Brazilian Buffet";
$phone = "510-814-2012";
$address = "190b Mississippi St, Portland, OR 97221";
$hours = "9am - ?";
$test_cuisine_type_id = $test_cuisine_type->getId();
$test_restaurant = new Restaurant($id, $name, $phone, $address, $hours, $test_cuisine_type_id);
$test_restaurant->save();
//Act
$test_cuisine_type->delete();
//Assert
$this->assertEquals([], Restaurant::getAll());
}
示例11: Cuisine
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());
}
示例12: Cuisine
function test_deleteReviews()
{
$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();
$user = "yoloswag1959";
$stars = 3;
$headline = "It is aight.";
$body = "Yeah, pretty aight bro";
$restaurant_id = $test_restaurant->getId();
$test_review = new Review($user, $stars, $headline, $body, $restaurant_id);
$test_review->save();
$user2 = "6969babygirl";
$stars2 = 3;
$headline2 = "XOXO";
$body2 = "I cant even";
$restaurant_id2 = $test_restaurant->getId();
$test_review2 = new Review($user2, $stars2, $headline2, $body2, $restaurant_id2);
$test_review2->save();
$test_restaurant->delete();
$result = Review::getAll();
//var_dump($result);
$this->assertEquals([], $result);
}
示例13: testGetRestaurants
function testGetRestaurants()
{
$type = "Thai";
$id = null;
$test_Cuisine = new Cuisine($type, $id);
$test_Cuisine->save();
$test_Restaurant = new Restaurant("Pok Pok", $id, "555-456-2345", "123 abcd street", "http://www.helloworld.com", $test_Cuisine->getId());
$test_Restaurant->save();
$test_Restaurant2 = new Restaurant("Whiskey Soda Lounge", $id, "555-555-5555", "678 DEF street", "http://www.pokpok.com", $test_Cuisine->getId());
$test_Restaurant2->save();
$result = $test_Cuisine->getRestaurants();
$this->assertEquals([$test_Restaurant, $test_Restaurant2], $result);
}
示例14: 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());
}
示例15: testGetRestaurants
function testGetRestaurants()
{
//Arrange
$type = "Italian";
$id = null;
$test_cuisine = new Cuisine($type, $id);
$test_cuisine->save();
$test_cuisine_id = $test_cuisine->getId();
$description = "OK Chinese food";
$name = "City Chinese";
$test_restaurant = new Restaurant($description, $id, $test_cuisine_id, $name);
$test_restaurant->save();
$description2 = "OK Mexican";
$name2 = "City Mexican";
$test_restaurant2 = new Restaurant($description2, $id, $test_cuisine_id, $name2);
$test_restaurant2->save();
//Act
$result = $test_cuisine->getRestaurants();
//Assert
$this->assertEquals([$test_restaurant, $test_restaurant2], $result);
}