@@ 12-24 (lines=13) @@ | ||
9 | ||
10 | class Todo extends Model{ |
|
11 | ||
12 | public function getAll(){ |
|
13 | ||
14 | $database = Database::openConnection(); |
|
15 | $query = "SELECT todo.id AS id, users.id AS user_id, users.name AS user_name, todo.content "; |
|
16 | $query .= "FROM users, todo "; |
|
17 | $query .= "WHERE users.id = todo.user_id "; |
|
18 | ||
19 | $database->prepare($query); |
|
20 | $database->execute(); |
|
21 | $todo = $database->fetchAllAssociative(); |
|
22 | ||
23 | return $todo; |
|
24 | } |
|
25 | ||
26 | public function create($userId, $content){ |
|
27 |
@@ 275-286 (lines=12) @@ | ||
272 | * @param integer $userId |
|
273 | * @return array |
|
274 | */ |
|
275 | public function getNotifications($userId){ |
|
276 | ||
277 | $database = Database::openConnection(); |
|
278 | $query = "SELECT target, count FROM notifications WHERE user_id = :user_id"; |
|
279 | ||
280 | $database->prepare($query); |
|
281 | $database->bindValue(":user_id", $userId); |
|
282 | $database->execute(); |
|
283 | ||
284 | $notifications = $database->fetchAllAssociative(); |
|
285 | return $notifications; |
|
286 | } |
|
287 | ||
288 | /** |
|
289 | * Clear Notifications for a specific target |