Guest User

Untitled

a guest
Nov 27th, 2018
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.33 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Class name  : Database Class  G
  4.  * @Author: Muhanned Mohammed Salim Al-Risi
  5.  * @Mail : kaka9909@hotmail.com  
  6.  * @country:Sultanat of  Oman
  7.  * @param: this  class  is  V1  and  its free for use  but don't change the copyright  :)
  8.  */
  9.  
  10.  class db{
  11.    
  12.     private $db=array();
  13.    
  14.     // connect function
  15.     public function  connect($local,$user,$pass,$dbname){
  16.         $this->db['localhost']=!empty($local)?$local:false;
  17.         $this->db['username']=!empty($user)?$user:false;
  18.         $this->db['password']=!empty($pass)?$pass:false;
  19.         $this->db['dbname']=!empty($dbname)?$dbname:false;
  20.        
  21.     $this->db['connect']=mysql_connect($this->db['localhost'],$this->db['username'],$this->db['password']) or die("Database Error ".mysql_error());
  22.     $this->db['select']=mysql_select_db($this->db['dbname']) or die(mysql_error());
  23.     }
  24.    
  25.     // close function
  26.     public function close(){
  27.         mysql_close($this->db['connect']);
  28.     }
  29.    
  30.     //query @var
  31.     public $sql=array();
  32.    
  33.     #query  function
  34.    
  35.     public function query($sql){
  36.         $this->sql['query']=!empty($sql)?$sql:die("Empty source ");
  37.         $this->sql['querys']= mysql_query($this->sql['query']) or die(mysql_error());
  38.         return $this->sql['querys'];
  39.     }
  40.    
  41.     public function fetch($query){
  42.         $this->sql['fetch']=mysql_fetch_assoc($query) or die(mysql_error());
  43.         return $this->sql['fetch'];
  44.     }
  45.      
  46.    
  47.    
  48.    
  49.  }
  50.  
  51. ?>
Add Comment
Please, Sign In to add comment