Advertisement
Guest User

Untitled

a guest
May 31st, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.36 KB | None | 0 0
  1. <?php
  2.  
  3. class Database{
  4.  
  5.   private $hostname;
  6.   private $databasename;
  7.   private $username;
  8.   private $password;
  9.   private $connect;
  10.   public $result;
  11.  
  12.  
  13.   public function __construct($hostname, $databasename, $username, $password){
  14.    
  15.     $this->hostname = $hostname;
  16.     $this->databasename = $databasename;
  17.     $this->username = $username;
  18.     $this->password = $password;
  19.    
  20.     $this->connect = MySQL_Connect($hostname, $username, $password) or die(MySQL_Error());
  21.     MySQL_Select_Db($this->databasename);
  22.   }
  23.  
  24.   public function execute($sql){
  25.     $this->sql = $sql;
  26.     $this->result = MySQL_Query($this->sql) or die(MySQL_Error());
  27.   }
  28.  
  29.  
  30.   private function fetch(){
  31.     include('Security.class.php');
  32.     $numargs = func_num_args();
  33.     $arg_list = func_get_args();
  34.     while($row = MySQL_Fetch_Object($this->result)){
  35.       for ($i = 0; $i < $numargs; $i++) {
  36.         if(isset($this->f1)){
  37.           echo $this->f1;
  38.         }
  39.         echo Security::h($row->$arg_list[$i]);
  40.         if(isset($this->f2)){
  41.           echo $this->f2;
  42.         }
  43.       }
  44.     }
  45.   }
  46.  
  47.   private function getFormatting($f1,$f2){
  48.     $this->f1 = $f1;
  49.     $this->f2 = $f2;
  50.   }
  51.  
  52.  
  53.  
  54.   /*private function __destruct(){
  55.   $close = MySQL_Close($this->connect);
  56.   if($close){
  57.     echo "Database connection has been closed succesfully";}
  58.   } */
  59. }
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement