Пример #1
0
 public static function setPostModel($id)
 {
     $db = Index::DB();
     $query = $db->prepare("SELECT * FROM posts WHERE id = ?  ORDER BY date DESC LIMIT 1 ");
     $query->execute([$id]);
     self::$data['article'] = $query->fetch();
     self::$data['article']['text'] = Home::toBB(self::$data['article']['text']);
     $query = $db->prepare("SELECT * FROM comms WHERE post_id = ? ORDER BY date DESC ");
     $query->execute([$id]);
     self::$data['comms'] = $query->fetchAll();
     foreach (self::$data['comms'] as &$comm) {
         $comm['text'] = html_entity_decode($comm['text']);
     }
     return true;
 }