Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class News
- {
- public static function getNewsItemById($id)
- {
- }
- public static function getNewsList()
- {
- $host = 'localhost';
- $dbname = 'mvc_site';
- $user = 'root';
- $password = '';
- $db = new PDO("mysql:host = $host; dbname = $dbname", $user, $password);
- $newList = array();
- $result = $db->query('SELECT id, title, date, short_content'
- .'FROM news'
- .'RODER BY date DESC'
- .'LIMIT 10');
- $i = 0;
- while($row = $result->fetch()) {
- $newList[$i]['id'] = $row['id'];
- $newList[$i]['title'] = $row['title'];
- $newList[$i]['date'] = $row['date'];
- $newList[$i]['short_content'] = $row['short_content'];
- $i++;
- }
- return $newList;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement