

<?php

include(ROOT.'/components/Db.php');
class News {

    public static function getNewsItemById($id){
        $id = intval($id);

        if($id){

            $db = Db::getConnection();

            $result = $db->query('SELECT * FROM news WHERE  id='.$id);

            $newItem = $result->fetch();

            return $newItem;
        }


    }

    public static  function getNewsList(){
        $db = Db::getConnection();

        $newsList = array();
        $result = $db->query('SELECT * FROM news');


        $i = 0;
        while($row = $result->fetch()){

            $newsList[$i]['id'] = $row['id'];
            $newsList[$i]['title'] = $row['title'];
            $newsList[$i]['short_content'] = $row['short_content'];
            $newsList[$i]['content'] = $row['Content'];
            $i++;
        }

        return $newsList;
    }
}
