当前位置: 首页>>代码示例>>PHP>>正文


PHP Food::getFood方法代码示例

本文整理汇总了PHP中Food::getFood方法的典型用法代码示例。如果您正苦于以下问题:PHP Food::getFood方法的具体用法?PHP Food::getFood怎么用?PHP Food::getFood使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Food的用法示例。


在下文中一共展示了Food::getFood方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: addFood

 public static function addFood($id, &$shoppingArray, $quantity = 0)
 {
     if ($id == 0) {
         return array();
     }
     // Prepare needed data
     $food = Food::getFood($id);
     $foodComponents = FoodComponent::getComponents($id);
     if (sizeof($foodComponents) == 0) {
         // Default to serving size in this case
         if ($quantity == 0) {
             $quantity = $food["quantity"];
         }
         // No components, just add entry for self
         self::addShopping($shoppingArray, $id, $food, $quantity);
     } else {
         // Default to recipe quantity in this case
         if ($quantity == 0) {
             $quantity = $food["recipeQuantity"];
         }
         if ($quantity == 0) {
             $quantity = $food["quantity"];
         }
         // Return shopping for each component
         foreach ($foodComponents as $foodComponent) {
             // Determine component quantity needed
             if ($food["recipeQuantity"] == 0) {
                 $food["recipeQuantity"] = $food["quantity"];
             }
             if ($food["recipeQuantity"] == 0) {
                 $food["recipeQuantity"] = 1;
             }
             $componentQuantity = $foodComponent["quantity"] * $quantity / $food["recipeQuantity"];
             self::addFood($foodComponent["componentId"], $shoppingArray, $componentQuantity);
         }
     }
 }
开发者ID:ncowan15,项目名称:FoodApp3,代码行数:37,代码来源:shoppingList.php

示例3: function

<?php

require 'classes/Food.php';
// get all food items route
$app->get('/food/', function () use($session) {
    // if($session->isValidRequest() == 0){
    // 	$session->goodnight();
    // }
    try {
        $return = array();
        $return['success'] = true;
        $return['data'] = Food::getFood();
        $return['time'] = time();
        //$return['id'] = $_SESSION['user_id'];
        $return['sid'] = session_id();
        echo json_encode($return);
    } catch (Exception $e) {
        echo json_encode($e->getMessage());
    }
});
开发者ID:srigdev,项目名称:AuthApiExample,代码行数:20,代码来源:Food.php

示例4: calculateComponents

 public static function calculateComponents($parentId)
 {
     $returnArray = array();
     if ($parentId == 0) {
         return $returnArray;
     }
     // Prepare needed data
     $parentFood = Food::getFood($parentId);
     $foodComponents = FoodComponent::getComponents($parentId);
     // Calculate nutrition for each component
     foreach ($foodComponents as $foodComponent) {
         // Determine quantity needed for one serving of parent food
         if ($parentFood["recipeQuantity"] == 0) {
             $parentFood["recipeQuantity"] = 1;
         }
         $quantity = $foodComponent["quantity"] * $parentFood["quantity"] / $parentFood["recipeQuantity"];
         // Calculate component nutrition at that quantity
         $componentNutrition = self::calculate($foodComponent["componentId"], $quantity);
         // Add component nutrition to output array
         $returnArray[] = $componentNutrition;
     }
     return $returnArray;
 }
开发者ID:ncowan15,项目名称:FoodApp3,代码行数:23,代码来源:componentNutrition.php


注:本文中的Food::getFood方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。