Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.26 KB | None | 0 0
  1. <?php
  2. class MySQL {
  3.     /*   Main Config */
  4.     private $host = "localhost";
  5.     private $user = "reeciebo_clients";
  6.     private $password = "ilove2sk8";
  7.    
  8.     private $db_siteroot = "reeciebo_siteroot";
  9.     private $db_clients = "reeciebo_clients";
  10.     //// END
  11.    
  12.     /* Variables */
  13.     private $db; private $table; private $fields;
  14.     private $sql; private $query;
  15.     private $arr;
  16.     //// END
  17.    
  18.     public function __construct() {
  19.            
  20.             mysql_connect($this->host, $this->user, $this->path) or die(mysql_error()) ; //on Instantiation - A new connection will be created
  21.                
  22.     }
  23.    
  24.     /* Methods */
  25.     public function getFields($db, $table, $fields) {
  26.    
  27.             if (isset($db, $table, $fields)) {
  28.                
  29.                     mysql_select_db($this->db) or die(mysql_error());
  30.                     $sql = "SELECT " . $this->fields . " FROM `" . $this->table . "`";
  31.                     $query = mysql_query($sql) or die(mysql_error());
  32.                    
  33.                     if (mysql_num_rows($query) == 0) {
  34.                        
  35.                         return false;
  36.                         exit;
  37.                        
  38.                     }
  39.                    
  40.                     $this->fields = explode(",", $this->fields);
  41.                     while ($row = mysql_fetch_assoc($query)) {
  42.                        
  43.                         foreach ($this->fields as $val) {
  44.                                
  45.                             $arr['$val'] = $row['$val'];
  46.                            
  47.                         }
  48.                        
  49.                     }
  50.                 return $arr;
  51.             }
  52.            
  53.         return false;
  54.    
  55.     }
  56.     //// END
  57.  
  58. }
  59. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement