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


PHP Food類代碼示例

本文整理匯總了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 "";
 }
開發者ID:asjs-dev,項目名稱:lab.coop,代碼行數:26,代碼來源:API.php

示例2: putIn

 public function putIn(Food $content)
 {
     if (in_array($content->getType(), $this->forbiddenFood)) {
         throw new \ForbiddenFoodTypeException($content->getType());
     }
     $this->content = $content;
 }
開發者ID:keymic,項目名稱:Employees,代碼行數:7,代碼來源:Microwave.php

示例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;
 }
開發者ID:CcrisS,項目名稱:PHP-Patterns,代碼行數:10,代碼來源:ClientH.php

示例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;
 }
開發者ID:zhaoyiyi,項目名稱:php-project,代碼行數:10,代碼來源:FoodDB.php

示例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;
 }
開發者ID:bswiatek,項目名稱:wzorce,代碼行數:10,代碼來源:Client.php

示例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;
 }
開發者ID:arvin-tcm,項目名稱:CS526_Web,代碼行數:11,代碼來源:food_repository.php

示例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;
 }
開發者ID:asjs-dev,項目名稱:lab.coop,代碼行數:14,代碼來源:Calories.class.php

示例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']);
 }
開發者ID:mawaha,項目名稱:tracker,代碼行數:7,代碼來源:FoodsTableSeeder.php

示例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);
 }
開發者ID:quanit94,項目名稱:ABCKitchen,代碼行數:7,代碼來源:MenuController.php

示例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.');
     }
 }
開發者ID:Thinlt,項目名稱:hadasai,代碼行數:16,代碼來源:CategoryController.php

示例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');
     }
 }
開發者ID:milos01,項目名稱:fridgeeapp.tk,代碼行數:9,代碼來源:UserController.php

示例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));
     }
 }
開發者ID:doankhoi,項目名稱:CrawlerDataFood,代碼行數:15,代碼來源:DB.php

示例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());
 }
開發者ID:mindaugas-valinskis,項目名稱:doophp,代碼行數:54,代碼來源:MainController.php

示例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;
 }
開發者ID:ncowan15,項目名稱:FoodApp3,代碼行數:15,代碼來源:whereUsed.php

示例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());
 }
開發者ID:quanit94,項目名稱:ABCKitchen,代碼行數:16,代碼來源:FoodController.php


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