本文整理匯總了PHP中Food::getById方法的典型用法代碼示例。如果您正苦於以下問題:PHP Food::getById方法的具體用法?PHP Food::getById怎麽用?PHP Food::getById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Food
的用法示例。
在下文中一共展示了Food::getById方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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;
}