BlogManager.php 819 Bytes
Newer Older
1 2 3
<?php
class BlogManager extends Base
{
Corentin Bettiol's avatar
Corentin Bettiol committed
4
    public function getBlog($page)
5
    {
Corentin Bettiol's avatar
Corentin Bettiol committed
6 7 8
        $start = $page*5;
        $stop = $start + 5;

9
        $db = $this->dbConnect();
Corentin Bettiol's avatar
Corentin Bettiol committed
10 11
        $req = $db->prepare('SELECT * FROM l3m_blog ORDER BY id DESC LIMIT '. $start .', '. $stop .'');
        $posts = $req->fetch();
12

Corentin Bettiol's avatar
Corentin Bettiol committed
13
        return $posts;
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
    }

    public function getBlogPost($link)
    {

        $link = htmlspecialchars($link);

        $title = str_replace("-", " ", $link);

        $db = $this->dbConnect();
        $req = $db->prepare('SELECT * FROM l3m_blog WHERE title = ?');
        $req->execute(array($title));
        $post = $req->fetch();

        if($post == false)
            return false;

        $post["link"] = $link;
        $post['datetime'] = new DateTime($post['time']);

        return $post;
    }
}