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