public function deleteById($id) { $selectId = filter_var($id, FILTER_SANITIZE_NUMBER_INT); $calories = new Calories(); $foodExistsInCaloriesList = $calories->foodExistsInCaloriesList($selectId); if ($foodExistsInCaloriesList) { return array("success" => false); } else { $result = SQL::query("DELETE FROM foods WHERE id = " . $selectId . ";"); return array("success" => $result); } }
protected function calories() { if (!$this->session->status()) { return $this->_response("Authentication Required", 401); } $calories = new Calories(); if ($this->method == 'GET') { return $calories->getList(); } else { if ($this->method == 'POST') { if ($this->data) { return $calories->addEntry($this->data); } } else { if ($this->method == 'DELETE') { if ($this->id) { return $calories->deleteById($this->id); } } } } return ""; }