@@ -12,19 +12,19 @@ discard block |
||
| 12 | 12 | public $amount; |
| 13 | 13 | public $image; |
| 14 | 14 | |
| 15 | - public function __construct($db){ |
|
| 15 | + public function __construct($db) { |
|
| 16 | 16 | $this->conn = $db; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public function read($amount = false){ |
|
| 19 | + public function read($amount = false) { |
|
| 20 | 20 | |
| 21 | 21 | $query = " |
| 22 | 22 | SELECT ID as id, Title as title, DefaultAmout as amount, Calories as calories, Image as image |
| 23 | 23 | FROM ". $this->db_table . " |
| 24 | 24 | WHERE UserID = :userid"; |
| 25 | 25 | |
| 26 | - if($amount){ |
|
| 27 | - $query .= " LIMIT ". $amount; |
|
| 26 | + if ($amount) { |
|
| 27 | + $query .= " LIMIT " . $amount; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | $stmt = $this->conn->prepare($query); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public function create(){ |
|
| 38 | + public function create() { |
|
| 39 | 39 | |
| 40 | 40 | $query = " |
| 41 | 41 | INSERT INTO " . $this->db_table . " SET |
@@ -46,11 +46,11 @@ discard block |
||
| 46 | 46 | Image = :image |
| 47 | 47 | "; |
| 48 | 48 | |
| 49 | - $this->userid=htmlspecialchars(strip_tags($this->userid)); |
|
| 50 | - $this->title=htmlspecialchars(strip_tags($this->title)); |
|
| 51 | - $this->calories=htmlspecialchars(strip_tags($this->calories)); |
|
| 52 | - $this->amount=htmlspecialchars(strip_tags($this->amount)); |
|
| 53 | - $this->image=htmlspecialchars(strip_tags($this->image)); |
|
| 49 | + $this->userid = htmlspecialchars(strip_tags($this->userid)); |
|
| 50 | + $this->title = htmlspecialchars(strip_tags($this->title)); |
|
| 51 | + $this->calories = htmlspecialchars(strip_tags($this->calories)); |
|
| 52 | + $this->amount = htmlspecialchars(strip_tags($this->amount)); |
|
| 53 | + $this->image = htmlspecialchars(strip_tags($this->image)); |
|
| 54 | 54 | |
| 55 | 55 | $stmt = $this->conn->prepare($query); |
| 56 | 56 | $stmt->bindParam(":userid", $this->userid); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $stmt->bindParam(":calories", $this->calories); |
| 60 | 60 | $stmt->bindParam(":image", $this->image); |
| 61 | 61 | |
| 62 | - if($stmt->execute()){ |
|
| 62 | + if ($stmt->execute()) { |
|
| 63 | 63 | $this->id = $this->conn->lastInsertId(); |
| 64 | 64 | return true; |
| 65 | 65 | } |
@@ -68,21 +68,21 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - public function delete(){ |
|
| 71 | + public function delete() { |
|
| 72 | 72 | |
| 73 | 73 | $query = " |
| 74 | 74 | DELETE FROM " . $this->db_table . " |
| 75 | 75 | WHERE ID = :id AND UserID = :userid |
| 76 | 76 | "; |
| 77 | 77 | |
| 78 | - $this->id=htmlspecialchars(strip_tags($this->id)); |
|
| 79 | - $this->userid=htmlspecialchars(strip_tags($this->userid)); |
|
| 78 | + $this->id = htmlspecialchars(strip_tags($this->id)); |
|
| 79 | + $this->userid = htmlspecialchars(strip_tags($this->userid)); |
|
| 80 | 80 | |
| 81 | 81 | $stmt = $this->conn->prepare($query); |
| 82 | 82 | $stmt->bindParam(":id", $this->id); |
| 83 | 83 | $stmt->bindParam(":userid", $this->userid); |
| 84 | 84 | |
| 85 | - if($stmt->execute()){ |
|
| 85 | + if ($stmt->execute()) { |
|
| 86 | 86 | |
| 87 | 87 | return true; |
| 88 | 88 | |
@@ -12,11 +12,11 @@ discard block |
||
| 12 | 12 | public $amount; |
| 13 | 13 | public $date; |
| 14 | 14 | |
| 15 | - public function __construct($db){ |
|
| 15 | + public function __construct($db) { |
|
| 16 | 16 | $this->conn = $db; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public function readByDay(){ |
|
| 19 | + public function readByDay() { |
|
| 20 | 20 | |
| 21 | 21 | $query = " |
| 22 | 22 | SELECT ID as id, Title as title, Calories as calories, Amount as amount |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function readDays($order = 'DESC'){ |
|
| 37 | + public function readDays($order = 'DESC') { |
|
| 38 | 38 | |
| 39 | 39 | $query = " |
| 40 | 40 | SELECT Date as date FROM ". $this->db_table . " |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - public function create(){ |
|
| 53 | + public function create() { |
|
| 54 | 54 | |
| 55 | 55 | $query = " |
| 56 | 56 | INSERT INTO " . $this->db_table . " SET |
@@ -61,11 +61,11 @@ discard block |
||
| 61 | 61 | Date = :date |
| 62 | 62 | "; |
| 63 | 63 | |
| 64 | - $this->userid=htmlspecialchars(strip_tags($this->userid)); |
|
| 65 | - $this->title=htmlspecialchars(strip_tags($this->title)); |
|
| 66 | - $this->calories=htmlspecialchars(strip_tags($this->calories)); |
|
| 67 | - $this->amount=htmlspecialchars(strip_tags($this->amount)); |
|
| 68 | - $this->date=htmlspecialchars(strip_tags($this->date)); |
|
| 64 | + $this->userid = htmlspecialchars(strip_tags($this->userid)); |
|
| 65 | + $this->title = htmlspecialchars(strip_tags($this->title)); |
|
| 66 | + $this->calories = htmlspecialchars(strip_tags($this->calories)); |
|
| 67 | + $this->amount = htmlspecialchars(strip_tags($this->amount)); |
|
| 68 | + $this->date = htmlspecialchars(strip_tags($this->date)); |
|
| 69 | 69 | |
| 70 | 70 | $stmt = $this->conn->prepare($query); |
| 71 | 71 | $stmt->bindParam(":userid", $this->userid); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $stmt->bindParam(":amount", $this->amount); |
| 75 | 75 | $stmt->bindParam(":date", $this->date); |
| 76 | 76 | |
| 77 | - if($stmt->execute()){ |
|
| 77 | + if ($stmt->execute()) { |
|
| 78 | 78 | $this->id = $this->conn->lastInsertId(); |
| 79 | 79 | return true; |
| 80 | 80 | } |
@@ -83,21 +83,21 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - public function delete(){ |
|
| 86 | + public function delete() { |
|
| 87 | 87 | |
| 88 | 88 | $query = " |
| 89 | 89 | DELETE FROM " . $this->db_table . " |
| 90 | 90 | WHERE ID = :id AND UserID = :userid |
| 91 | 91 | "; |
| 92 | 92 | |
| 93 | - $this->id=htmlspecialchars(strip_tags($this->id)); |
|
| 94 | - $this->userid=htmlspecialchars(strip_tags($this->userid)); |
|
| 93 | + $this->id = htmlspecialchars(strip_tags($this->id)); |
|
| 94 | + $this->userid = htmlspecialchars(strip_tags($this->userid)); |
|
| 95 | 95 | |
| 96 | 96 | $stmt = $this->conn->prepare($query); |
| 97 | 97 | $stmt->bindParam(":id", $this->id); |
| 98 | 98 | $stmt->bindParam(":userid", $this->userid); |
| 99 | 99 | |
| 100 | - if($stmt->execute()){ |
|
| 100 | + if ($stmt->execute()) { |
|
| 101 | 101 | |
| 102 | 102 | return true; |
| 103 | 103 | |