本文整理汇总了PHP中Food类的典型用法代码示例。如果您正苦于以下问题:PHP Food类的具体用法?PHP Food怎么用?PHP Food使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Food类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: food
protected function food()
{
if (!$this->session->status()) {
return $this->_response("Authentication Required", 401);
}
$food = new Food();
if ($this->method == 'GET') {
if ($this->id) {
return $food->getById($this->id);
}
return $food->getList();
} else {
if ($this->method == 'POST') {
if ($this->data) {
return $food->create($this->data);
}
} else {
if ($this->method == 'DELETE') {
if ($this->id) {
return $food->deleteById($this->id);
}
}
}
}
return "";
}
示例2: putIn
public function putIn(Food $content)
{
if (in_array($content->getType(), $this->forbiddenFood)) {
throw new \ForbiddenFoodTypeException($content->getType());
}
$this->content = $content;
}
示例3: wrapComponent
private function wrapComponent(IComponent $component)
{
$component = new ProgramLang($component);
$component->setFeature($this->progLange);
$component = new Hardware($component);
$component->setFeature($this->hardware);
$component = new Food($component);
$component->setFeature($this->food);
return $component;
}
示例4: getFoodById
public static function getFoodById($id)
{
self::$db = Database::getDB();
$query = "select * from food where Food_id='{$id}'";
$result = self::$db->query($query);
$item = $result->fetch();
$food = new Food($item["Food_Catagory"], $item["Food_Price"], $item["Food_Instock"], $item["Food_description"], $item["Food_mark"], $item["Food_Name"], $item["Food_Image"], $item["Discount_price"], $item["Viewed_times"], $item["Sales_volume"]);
$food->setId($item["Food_id"]);
return $food;
}
示例5: wrapComponent
private function wrapComponent(IComponent $component)
{
$component = new ProgramLang($component);
$component->setFeature("php");
$component = new Hardware($component);
$component->setFeature("lin");
$component = new Food($component);
$component->setFeature("veg");
return $component;
}
示例6: getfood
public static function getfood($food_id)
{
global $db;
$query = "SELECT * FROM foods WHERE foodID = {$food_id}";
$result = $db->query($query);
$row = $result->fetch();
$category = CategoryRepository::getCategory($row['categoryID']);
$food = new Food($row['calories'], $row['foodTitle'], $row['foodPrice'], $category);
$food->setId($row['foodID']);
return $food;
}
示例7: getList
public function getList()
{
$food = new Food();
$userId = $_SESSION["userId"];
$result = SQL::query("SELECT * FROM calories WHERE user_id = " . $userId . ";");
$response = array();
for ($i = 0; $i < $result->num_rows; $i++) {
$line = SQL::fetchAssoc($result);
$foodData = $food->getById($line["food_id"]);
$line["food_data"] = $foodData;
array_push($response, $line);
}
return $response;
}
示例8: run
public function run()
{
Food::truncate();
Food::create(['name' => 'Oats, Rolled', 'protein' => '0.11', 'carbohydrate' => '0.604', 'fat' => '0.081']);
Food::create(['name' => 'Soy Milk', 'protein' => '0.033', 'carbohydrate' => '0.06', 'fat' => '0.018']);
Food::create(['name' => 'Banana', 'protein' => '0.011', 'carbohydrate' => '0.23', 'fat' => '0.003']);
}
示例9: add_food_get
public function add_food_get($menu_id)
{
$menu_name = Menu::where("menu_id", $menu_id)->first();
$this->_data['foods'] = Food::paginate(10);
$this->_data['menus'] = DB::table("menus")->join("menu_foods", "menus.menu_id", "=", "menu_foods.menu_id")->join("foods", "menu_foods.food_id", "=", "foods.food_id")->where("menus.menu_id", $menu_id)->orderBy("menu_foods.created_at", "desc")->get();
return View::make("admin.content.menu.add_food", $this->_data)->with("titlePage", "Add Food In Menu")->with("titleTable", "Thêm món ăn vào thực đơn: <strong>" . $menu_name->menu_name . "</strong>")->with("menu_id", $menu_id);
}
示例10: findModel
/**
* Finds the User model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @param integer $create_date
* @return GwTransactionLog the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Food::findOne(['id' => $id])) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
示例11: deleteFood
public function deleteFood($id)
{
$food = Food::find($id);
if ($food->delete()) {
return Redirect::route('userHome')->with('success', 'User deleted successfuly');
} else {
return Redirect::route('userHome')->with('fail', 'Error while deleting food');
}
}
示例12: isAvaiableInFoodTable
/**
* Check name is exist in food table
* return null if not exist
* @param $name name Vietnamese
* @return Food
*/
public function isAvaiableInFoodTable($name)
{
$slug = Utils::normalizeSlug($name);
$sql = "select * from monan where slug = '" . $slug . "' limit 1";
$query = mysql_query($sql);
if (mysql_num_rows($query) > 0) {
return Food::create(mysql_fetch_array($query));
}
}
示例13: test
public function test()
{
$this->load()->model('Food');
$food = new Food();
echo '<pre>';
//print_r( $food->getById(14) );
//print_r( $food->getById(14, array('limit'=>1)) );
//print_r( $food->limit(10) );
//print_r( $food->limit(10,'id,name') );
//print_r( $food->limit(10,'name','id') );
//print_r( $food->limit(10,'name,id','location') );
//print_r( Food::_limit(10) );
//print_r( $food->getOne() );
//print_r( Food::_getOne() );
//$food->location = 'Asia';
//$food->food_type_id = 10;
print_r($food->count());
print_r(Food::_count());
print_r(Food::_count($food));
//Doo::cache('php')->set('foodtotal', Food::_count($food));
//echo '<h1>'. Doo::cache('php')->get('foodtotal') .'</h1>';
print_r(Food::getById__first(6));
//$food->id = 14;
//print_r( $food->getOne() );
// print_r( $food->find() );
//print_r( Food::_find($food) );
//print_r( $food->getById_location__first(6, 'Malaysia') );
//print_r( $food->getById_location(6, 'Malaysia', array('limit'=>1)) );
//print_r( $food->relateFoodType($food, array('limit'=>'first')) );
//print_r( $food->relateFoodType($food) );
//print_r( $food->relateFoodType__first($food) );
//print_r( Food::getById__location__first(6, 'Malaysia') );
//print_r( Food::getById__location(6, 'Malaysia') );
//print_r( Food::getById__first(6) );
//print_r( Food::getByLocation('Malaysia') );
//print_r( Food::relateFoodType__first($food) );
//print_r( Food::relateFoodType() );
//print_r( Food::relateFoodType_first() );
//print_r( Food::_relate('', 'FoodType') );
//
//$f = new Food;
//print_r( $f->relate('FoodType') );
//print_r( $f->relate('FoodType', array('limit'=>'first')) );
# if update/delete/insert cache auto purged on the Model.
//$food->id = 6;
//$food->name = 'Wan Tan Mee';
//$food->update();
//print_r($food->find());
//$food->purgeCache(); #to delete cache manually
//Food::_purgeCache(); #to delete cache manually
# If no SQL is displayed, it means that the data are read from cache.
# And of course your Model have to extend DooSmartModel
print_r(Doo::db()->showSQL());
}
示例14: calculate
public static function calculate($id)
{
if ($id == 0) {
return array();
}
$food = Food::getFood($id);
$returnArray = array();
// Search food components table for input food
$foodComponents = FoodComponent::getComponentsWithChild($id);
foreach ($foodComponents as $foodComponent) {
$parentFood = Food::getFood($foodComponent["foodId"]);
$returnArray[] = array("foodId" => $parentFood["id"], "foodName" => $parentFood["name"], "componentId" => $food["id"], "componentName" => $food["name"], "quantity" => $foodComponent["quantity"], "unitOfMeasure" => $food["unitOfMeasure"]);
}
return $returnArray;
}
示例15: edit_post
public function edit_post($id)
{
$valid = Validator::make(Input::all(), Food::rule_edit_food($id), Food::$food_langs);
if ($valid->passes()) {
$data = Input::all();
$img = $data['food_image'];
$isUpload = $img->move("uploads/food/");
if ($isUpload) {
$data = array("food_name" => Input::get("food_name"), "food_price" => Input::get("food_price"), "food_description" => Input::get("food_description"), "food_image" => $img->getClientOriginalName(), "food_created_at" => date("Y-m-d"));
DB::table("foods")->where("food_id", $id)->update($data);
return Redirect::route("manage_food")->with("flash_success", "Chúc mừng bạn đã sửa món ăn thành công");
}
return Redirect::route("manage_food")->with("flash_error", "Không thể upload ảnh");
}
return Redirect::route("manage_food_edit_get", $id)->withInput()->with("flash_error", $valid->errors()->first());
}