当前位置: 首页>>代码示例>>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;未经允许,请勿转载。