示例#1
0
<?php

require_once "../Model/Database.php";
require_once "../Model/Food.php";
require_once "../Model/FoodDB.php";
$foods = FoodDB::getAll();
echo $foods;
示例#2
0
 public static function getHistory($count)
 {
     $foods = json_decode(FoodDB::getAll());
     $time = array();
     $t = time();
     foreach ($foods as $food) {
         if (isset($_COOKIE[$food->Food_id]) && $_COOKIE[$food->Food_id] >= strtotime('-7 day', $t)) {
             $time[$food->Food_id] = $_COOKIE[$food->Food_id];
         }
     }
     arsort($time);
     $results = array();
     foreach ($time as $key => $item) {
         $food = FoodDB::getFoodById($key);
         $results[] = $food;
         if (count($results) >= $count) {
             break;
         }
     }
     return $results;
 }