Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.75 KB | None | 0 0
  1. <?php
  2.  
  3.     class cmain{
  4.        
  5.         private $host;
  6.         private $user;
  7.         private $pass;
  8.         private $db;
  9.        
  10.         public function get($host,$user,$pass,$db){
  11.            
  12.             echo $this->host = $host;
  13.             echo $this->user = $user;
  14.             echo $this->pass = $pass;
  15.             echo $this->db   = $db;
  16.            
  17.         }
  18.  
  19.  
  20.         public function __construct() {
  21.          
  22.             $this->link = mysql_connect("$this->host","$this->user","$this->pass");
  23.             mysql_select_db($this->db,$this->link);
  24.                        
  25.         }
  26.        
  27.        
  28.        
  29.        
  30.        
  31.         public function select ($tbl,$uid){
  32.            
  33.            
  34.             $this->tbl = $tbl;
  35.             $this->uid = $uid;
  36.            
  37.            
  38.             if (empty($this->uid))
  39.                 $this->result = mysql_query("SELECT * FROM $this->tbl")or die (mysql_error());
  40.            
  41.            
  42.             if (!empty($this->uid))
  43.                 $this->result = mysql_query("SELECT * FROM $this->tbl WHERE id='$this->uid'")or die (mysql_error());
  44.  
  45.            
  46.             $this->return = array () ;
  47.            
  48.             while ($this->row = mysql_fetch_array( $this->result )) {
  49.                 $this->return [] = $this->row ;
  50.             }
  51.            
  52.             return ($this->return);
  53.         }
  54.  
  55.        
  56.        
  57.        
  58.        
  59.         public function __destruct() {
  60.            
  61.             mysql_close($this->link);
  62.            
  63.         }
  64.        
  65.     }
  66.  
  67.     $con = new cmain();
  68.  
  69.     require_once 'config.php';
  70.    
  71.     $con->get(host, user, pass, db);
  72.  
  73.     $tbl = "members";
  74.    
  75.     $result = $con->select($tbl, $_SESSION['user']);
  76.         ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement