本文整理汇总了PHP中Restaurant::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Restaurant::update方法的具体用法?PHP Restaurant::update怎么用?PHP Restaurant::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Restaurant
的用法示例。
在下文中一共展示了Restaurant::update方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addReview
public function addReview($data)
{
$this->user_id = $data['user_id'];
$this->restaurant_id = $data['restaurant_id'];
$this->content = $data['content'];
$this->rating = $data['rating'];
$this->created_at = $data['created_at'] = date('Y-m-d H:i:s');
$this->updated_at = $data['updated_at'] = date('Y-m-d H:i:s');
if ($this->create($data)) {
$restaurants = new Restaurant();
$restaurant = $restaurants->find('id', $this->restaurant_id);
$review_count = intval($restaurant['review_count']);
$rating = $review_count * intval($restaurant['rating']) + intval($this->rating);
$review_count += 1;
$rating /= $review_count;
$restaurants->update('id', $this->restaurant_id, ['rating' => $rating, 'review_count' => $review_count]);
$result['status'] = "success";
$result['success_text'] = "review added";
} else {
$result['status'] = "error";
$result['error_text'] = "review not added";
}
return json_encode($result);
}
示例2: Cuisine
function test_update()
{
$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_restaurant->update($restaurant_name2, $location2, $description2, $price2, $cuisine_id2);
$result = $test_restaurant->getName();
$this->assertEquals("The Red Dragon", $result);
}
示例3: testUpdate
function testUpdate()
{
//Arrange
$flavor = "Pizza";
$id = null;
$test_cuisine = new Cuisine($flavor, $id);
$name = "Pizza Party";
$phone_number = "123-456-7890";
$address = "1234 Pepperoni Lane";
$cuisine_id = $test_cuisine->getId();
$test_restaurant = new Restaurant($name, $phone_number, $address, $id, $cuisine_id);
$test_restaurant->save();
$new_name = "Burger Bash";
//Act
$test_restaurant->update($new_name);
//Assert
$this->assertEquals("Pizza", $test_cuisine->getFlavor());
}
示例4: Cuisine
function test_update()
{
//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();
$test_restaurant = new Restaurant($restaurant, $address, $phone, $cuisine_id, $id);
$test_restaurant->save();
$new_restaurant_name = "HobNob";
//Act
$test_restaurant->update($new_restaurant_name);
//Assert
$this->assertEquals("HobNob", $test_restaurant->getName());
}
示例5: testUpdate
function testUpdate()
{
//Arrange
$type = "french";
$id = null;
$test_cuisine = new Cuisine($type, $id);
$test_cuisine->save();
$name = "Petit Provence";
$phone = "555-555-5555";
$price = "\$\$";
$cuisine_id = $test_cuisine->getId();
// $id = null;
$test_restaurant = new Restaurant($name, $phone, $price, $cuisine_id);
$test_restaurant->save();
$new_name = "Escargot";
$new_phone = "666-666-6666";
$new_price = "\$\$\$";
// $cuisine_id = 1;
// $new_id = null;
$new_test_restaurant = new Restaurant($new_name, $new_phone, $new_price, $cuisine_id, $test_restaurant->getId());
// $new_test_restaurant->save();
// var_dump($new_test_restaurant);
//Act
$test_restaurant->update($new_name, $new_phone, $new_price);
//Assert
$this->assertEquals($test_restaurant, $new_test_restaurant);
}
示例6: Session
<?php
require_once 'model/session.php';
require_once 'model/order.php';
require_once 'model/restaurant.php';
$session = new Session();
$order = new Order();
$restaurant = new Restaurant();
if ($session->get_session_data('user_type') == 'admin') {
$restaurant->update('id', $_GET['id'], ['status' => 1]);
header('Location: admin-dashboard.php');
} else {
print_r("Something went wrong");
}
示例7: Cuisine
function test_update()
{
$name = "Chinese";
$id = null;
$test_cuisine = new Cuisine($name, $id);
$test_cuisine->save();
$place_name = "Happy House";
$address = "4234 N Interstate Ave, Portland OR 97217";
$phone = "503-287-9740";
$cuisine_id = $test_cuisine->getId();
$test_restaurant = new Restaurant($place_name, $id, $address, $phone, $cuisine_id);
$test_restaurant->save();
$new_place_name = "Very Happy House";
$new_address = "5000 N Interstate Ave, Portland OR 97217";
$new_phone = "503-287-9000";
$test_restaurant->update($new_place_name, $new_address, $new_phone);
$this->assertEquals("Very Happy House", $test_restaurant->getPlaceName());
$this->assertEquals("5000 N Interstate Ave, Portland OR 97217", $test_restaurant->getAddress());
$this->assertEquals("503-287-9000", $test_restaurant->getPhone());
}
示例8: Cuisine
function test_Update()
{
//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();
$column_to_update = "restaurant_name";
$new_information = "Veritable Quandary";
//Act
$test_restaurant->update($column_to_update, $new_information);
//Assert
$result = Restaurant::getAll();
$this->assertEquals("Veritable Quandary", $result[0]->getRestaurantName());
}
示例9: testUpdate
function testUpdate()
{
//Arrange
$restaurant_name = "Joes Burgers";
$id = null;
$test_restaurant = new Restaurant($restaurant_name, $id);
$test_restaurant->save();
$new_restaurant_name = "McDonalds";
//Act
$test_restaurant->update($new_restaurant_name);
//Assert
$this->assertEquals($new_restaurant_name, $test_restaurant->getRestaurantName());
}
示例10: Cuisine
function test_update()
{
//Arrange
$cuisine_type = "Italian";
$id = null;
$test_cuisine = new Cuisine($cuisine_type, $id);
$test_cuisine->save();
$name = "Taco Restaurant";
$phone = "(503) 777-9097";
$address = "7000 Beaverton Hillsdale HWY, Portland, OR 97221";
$hours = "7am - 2am";
$cuisine_id = $test_cuisine->getId();
$test_restaurant = new Restaurant($id, $name, $phone, $address, $hours, $cuisine_id);
$test_restaurant->save();
$new_name = "Taco Bell";
// $new_phone = "(402) 231-0911";
// $new_address = "902 Beaverton Hillsdale Hwy, Portland, OR 97211";
// $new_hours = "8am - 10pm";
//Act
$test_restaurant->update($new_name);
//Assert
$this->assertEquals("Taco Bell", $test_restaurant->getName());
}