Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2017
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. `public static function getNewsList(){
  2. /*$host = 'localhost';
  3. $dbname = 'davgabih_test';
  4. $user = 'davgabih_test';
  5. $password = 'Test3331';*/
  6. $db = new PDO("mysql:host=localhost;dbname=davgabih_test", 'davgabih_test', 'Test3331');
  7.  
  8. $newsList = array();
  9.  
  10. $result = $db->query('SELECT id, title, date, short_content'.'FROM news'.'OREDER BY date DESC'.'LIMIT 10');
  11.  
  12. $i = 0;
  13.  
  14. while($row = $result->fetch()){
  15. $newsList[$i]['id'] = $row['id'];
  16. $newsList[$i]['title'] = $row['title'];
  17. $newsList[$i]['date'] = $row['date'];
  18. $newsList[$i]['short_content'] = $row['short_content'];
  19. $i++;
  20. }
  21.  
  22. return $newsList;
  23.  
  24. }`
  25.  
  26. `public function actionIndex()
  27. {
  28. $newsList = array();
  29. $newsList = News::getNewsList();
  30.  
  31. echo "<pre>";
  32. print_r($newsList);
  33. echo "</pre>";
  34. return true;
  35. }`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement