| @@ 58-73 (lines=16) @@ | ||
| 55 | * @return array Array holds the data of the comment |
|
| 56 | * |
|
| 57 | */ |
|
| 58 | public function getById($commentId){ |
|
| 59 | ||
| 60 | $database = Database::openConnection(); |
|
| 61 | $query = "SELECT comments.id AS id, users.profile_picture, users.id AS user_id, users.name AS user_name, comments.content, comments.date "; |
|
| 62 | $query .= "FROM users, posts, comments "; |
|
| 63 | $query .= "WHERE comments.id = :id "; |
|
| 64 | $query .= "AND posts.id = comments.post_id "; |
|
| 65 | $query .= "AND users.id = comments.user_id LIMIT 1"; |
|
| 66 | ||
| 67 | $database->prepare($query); |
|
| 68 | $database->bindValue(':id', (int)$commentId); |
|
| 69 | $database->execute(); |
|
| 70 | ||
| 71 | $comment = $database->fetchAllAssociative(); |
|
| 72 | return $comment; |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * create Comment. |
|
| @@ 48-62 (lines=15) @@ | ||
| 45 | * @param string $fileId |
|
| 46 | * @return array Array holds the data of the file |
|
| 47 | */ |
|
| 48 | public function getById($fileId){ |
|
| 49 | ||
| 50 | $database = Database::openConnection(); |
|
| 51 | $query = "SELECT files.id AS id, files.filename, users.id AS user_id, users.name AS user_name, files.extension AS format, files.hashed_filename, files.date "; |
|
| 52 | $query .= "FROM users, files "; |
|
| 53 | $query .= "WHERE files.id = :id "; |
|
| 54 | $query .= "AND users.id = files.user_id LIMIT 1 "; |
|
| 55 | ||
| 56 | $database->prepare($query); |
|
| 57 | $database->bindValue(':id', (int)$fileId); |
|
| 58 | $database->execute(); |
|
| 59 | ||
| 60 | $file = $database->fetchAllAssociative(); |
|
| 61 | return $file; |
|
| 62 | } |
|
| 63 | ||
| 64 | /** |
|
| 65 | * get file by hashed name. |
|
| @@ 72-87 (lines=16) @@ | ||
| 69 | * @param string $hashedFileName |
|
| 70 | * @return array Array holds the data of the file |
|
| 71 | */ |
|
| 72 | public function getByHashedName($hashedFileName){ |
|
| 73 | ||
| 74 | $database = Database::openConnection(); |
|
| 75 | ||
| 76 | $query = "SELECT files.id AS id, files.filename, files.extension, files.hashed_filename "; |
|
| 77 | $query .= "FROM files "; |
|
| 78 | $query .= "WHERE hashed_filename = :hashed_filename "; |
|
| 79 | $query .= "LIMIT 1 "; |
|
| 80 | ||
| 81 | $database->prepare($query); |
|
| 82 | $database->bindValue(':hashed_filename', $hashedFileName); |
|
| 83 | $database->execute(); |
|
| 84 | ||
| 85 | $file = $database->fetchAssociative(); |
|
| 86 | return $file; |
|
| 87 | } |
|
| 88 | ||
| 89 | /** |
|
| 90 | * create file. |
|
| @@ 45-59 (lines=15) @@ | ||
| 42 | * @param string $newsfeedId |
|
| 43 | * @return array |
|
| 44 | */ |
|
| 45 | public function getById($newsfeedId){ |
|
| 46 | ||
| 47 | $database = Database::openConnection(); |
|
| 48 | $query = "SELECT newsfeed.id AS id, users.profile_picture, users.id AS user_id, users.name AS user_name, newsfeed.content, newsfeed.date "; |
|
| 49 | $query .= "FROM users, newsfeed "; |
|
| 50 | $query .= "WHERE newsfeed.id = :id "; |
|
| 51 | $query .= "AND users.id = newsfeed.user_id LIMIT 1 "; |
|
| 52 | ||
| 53 | $database->prepare($query); |
|
| 54 | $database->bindValue(':id', (int)$newsfeedId); |
|
| 55 | $database->execute(); |
|
| 56 | ||
| 57 | $feed = $database->fetchAllAssociative(); |
|
| 58 | return $feed; |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * create news feed. |
|
| @@ 72-86 (lines=15) @@ | ||
| 69 | * @param integer $postId |
|
| 70 | * @return array Array holds the data of the post |
|
| 71 | */ |
|
| 72 | public function getById($postId){ |
|
| 73 | ||
| 74 | $database = Database::openConnection(); |
|
| 75 | $query = "SELECT posts.id AS id, users.profile_picture, users.id AS user_id, users.name AS user_name, posts.title, posts.content, posts.date "; |
|
| 76 | $query .= "FROM users, posts "; |
|
| 77 | $query .= "WHERE posts.id = :id "; |
|
| 78 | $query .= "AND users.id = posts.user_id LIMIT 1 "; |
|
| 79 | ||
| 80 | $database->prepare($query); |
|
| 81 | $database->bindValue(':id', $postId); |
|
| 82 | $database->execute(); |
|
| 83 | ||
| 84 | $post = $database->fetchAssociative(); |
|
| 85 | return $post; |
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * create post |
|