SHARE
TWEET

Untitled

a guest Dec 23rd, 2017 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.   class database
  4.   {
  5.  
  6.     private $host;
  7.     private $user;
  8.     private $pass;
  9.     private $db;
  10.  
  11.  
  12.  
  13.     function __CONSTRUCT($host,$user,$pw,$db)
  14.     {
  15.    
  16.       $this->host = $host;
  17.       $this->user = $user;
  18.       $this->pass = $pw;
  19.       $this->db = $db;
  20.      
  21.     }
  22.    
  23.    
  24.    
  25.     public function connect()
  26.     {
  27.    
  28.       if(mysql_connect($this->host,$this->user,$this->pass) AND mysql_select_db($this->db))
  29.       {
  30.      
  31.         return true;
  32.        
  33.       }
  34.      
  35.       return mysql_error();
  36.      
  37.     }
  38.    
  39.  
  40.  
  41.     public function close()
  42.     {
  43.    
  44.       if(mysql_close($this->db))
  45.       {
  46.         return true;
  47.       }
  48.      
  49.       return false;
  50.      
  51.     }
  52.    
  53.    
  54.    
  55.     public function escape($str)
  56.     {
  57.    
  58.       return mysql_escape_string($str);
  59.      
  60.     }
  61.    
  62.    
  63.    
  64.     public function query($q)
  65.     {
  66.    
  67.       if(mysql_query($q))
  68.       {
  69.         return true;
  70.       }
  71.  
  72.       return mysql_error();
  73.      
  74.     }
  75.    
  76.    
  77.    
  78.     public function fetch($t,$q)
  79.     {
  80.    
  81.       switch($t)
  82.       {
  83.         case 'assoc':
  84.           return mysql_fetch_assoc($q);
  85.           break;
  86.         case 'array':
  87.           return mysql_fetch_array($q);
  88.           break;
  89.         case 'row':
  90.           return mysql_fetch_row($q);
  91.           break;
  92.       }
  93.  
  94.     }
  95.    
  96.     public function num_rows($q)
  97.     {
  98.    
  99.       return mysql_num_rows($q);
  100.      
  101.     }
  102.    
  103.    
  104.   }
  105.  
  106. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top