コード例 #1
0
 public function getPosts()
 {
     $this->array = array();
     $stmt = $this->mysqli->prepare("SELECT `Title`, `Text`, `Author`,`Description`, `Date` FROM " . self::$table);
     if (!$stmt) {
         throw new \Exception($this->mysqli->error);
     }
     $stmt->execute();
     $stmt->bind_result($title, $text, $author, $date);
     while ($stmt->fetch()) {
         $title = $this->parser->text($title);
         $author = $this->parser->text($author);
         $text = $this->parser->text($text);
         $description = $this->parser->text($description);
         $post = new PostModel($title, $text, $author, $description, $date);
         $this->array[$post->getUnique()] = $post;
     }
     return $this->array;
 }