public function findById($post_id) { // current $q = "SELECT\n id,\n published,\n date_deleted,\n post\n FROM posts\n WHERE id = :id"; $r = $this->db->prepare($q); $r->execute([":id" => $post_id]); $post = $r->fetch(); if ($post === false) { return array(); } $post = new \Aruna\PostViewModel(json_decode($post['post'], true), $post['date_deleted']); foreach ($this->findMentionsByPostId($post_id) as $mention) { if ($mention->type() == "reply") { $post->setComment($mention); } } foreach ($this->findMentionsByPostId($post_id) as $mention) { if ($mention->type() == "like") { $post->setLike($mention); } } $out = array($post); return $out; }