@@ 40-48 (lines=9) @@ | ||
37 | return $statement->fetchAll(); |
|
38 | } |
|
39 | ||
40 | public function getAll(int $userId): array |
|
41 | { |
|
42 | $query = 'SELECT * FROM `tasks` WHERE `userId` = :userId ORDER BY `id`'; |
|
43 | $statement = $this->getDb()->prepare($query); |
|
44 | $statement->bindParam('userId', $userId); |
|
45 | $statement->execute(); |
|
46 | ||
47 | return $statement->fetchAll(); |
|
48 | } |
|
49 | ||
50 | public function search($tasksName, int $userId, $status): array |
|
51 | { |
|
@@ 113-122 (lines=10) @@ | ||
110 | return $this->checkAndGetTask((int) $task->id, (int) $task->userId); |
|
111 | } |
|
112 | ||
113 | public function delete(int $taskId, int $userId): string |
|
114 | { |
|
115 | $query = 'DELETE FROM `tasks` WHERE `id` = :id AND `userId` = :userId'; |
|
116 | $statement = $this->getDb()->prepare($query); |
|
117 | $statement->bindParam('id', $taskId); |
|
118 | $statement->bindParam('userId', $userId); |
|
119 | $statement->execute(); |
|
120 | ||
121 | return 'The task was deleted.'; |
|
122 | } |
|
123 | } |
|
124 |