Advertisement
Guest User

Untitled

a guest
Aug 4th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.47 KB | None | 0 0
  1. <?php
  2.  
  3. class RSS {
  4.  
  5.     var $username = "root";
  6.     var $password = "password";
  7.     var $server = "localhost";
  8.     var $port = "3306";
  9.     var $databasename = "techno_noise";
  10.     var $tablename = "files";
  11.    
  12.     var $connection;
  13.  
  14.    
  15.     public function __construct() {
  16.         $this->connection = mysqli_connect(
  17.                                 $this->server,  
  18.                                 $this->username,  
  19.                                 $this->password,
  20.                                 $this->databasename,
  21.                                 $this->port
  22.                             );
  23.  
  24.         $this->throwExceptionOnError($this->connection);
  25.            
  26.     }
  27.         public function getFeatured() {
  28.  
  29.         $stmt = mysqli_prepare($this->connection, "SELECT * FROM files WHERE featured = true ");       
  30.         $this->throwExceptionOnError();
  31.        
  32.         mysqli_stmt_execute($stmt);
  33.         $this->throwExceptionOnError();
  34.        
  35.         $rowsFeatured = array();
  36.        
  37.         mysqli_stmt_bind_result($stmt, $row->filename, $row->dj, $row->name, $row->hash);
  38.        
  39.         while (mysqli_stmt_fetch($stmt)) {
  40.           $rowsFeatured[] = $row;
  41.           $row = new stdClass();
  42.           mysqli_stmt_bind_result($stmt, $row->filename, $row->dj, $row->name, $row->hash);
  43.         }
  44.        
  45.         mysqli_stmt_free_result($stmt);
  46.         mysqli_close($this->connection);
  47.    
  48.         return $rowsFeatured;
  49.        
  50.         }
  51.        
  52.         public function getNewest() {
  53.  
  54.         $stmt = mysqli_prepare($this->connection, "SELECT MAX(date) FROM files LIMIT 5");      
  55.         $this->throwExceptionOnError();
  56.        
  57.         mysqli_stmt_execute($stmt);
  58.         $this->throwExceptionOnError();
  59.        
  60.         $rowsNewest = array();
  61.        
  62.         mysqli_stmt_bind_result($stmt, $row->filename, $row->dj, $row->name, $row->hash);
  63.        
  64.         while (mysqli_stmt_fetch($stmt)) {
  65.           $rowsNewest[] = $row;
  66.           $row = new stdClass();
  67.           mysqli_stmt_bind_result($stmt, $row->filename, $row->dj, $row->name, $row->hash);
  68.         }
  69.        
  70.         mysqli_stmt_free_result($stmt);
  71.         mysqli_close($this->connection);
  72.    
  73.         return $rowsNewest;
  74.     }
  75.    
  76.         public function getBest() {
  77.  
  78.         $stmt = mysqli_prepare($this->connection, "SELECT MAX(ranking) FROM files LIMIT 5");       
  79.         $this->throwExceptionOnError();
  80.        
  81.         mysqli_stmt_execute($stmt);
  82.         $this->throwExceptionOnError();
  83.        
  84.         $rowsBest = array();
  85.        
  86.         mysqli_stmt_bind_result($stmt, $row->filename, $row->dj, $row->name, $row->hash);
  87.        
  88.         while (mysqli_stmt_fetch($stmt)) {
  89.           $rowsBest[] = $row;
  90.           $row = new stdClass();
  91.           mysqli_stmt_bind_result($stmt, $row->filename, $row->dj, $row->name, $row->hash);
  92.         }
  93.        
  94.         mysqli_stmt_free_result($stmt);
  95.         mysqli_close($this->connection);
  96.    
  97.         return $rowsBest;
  98.     }
  99.    
  100.    
  101.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement