Advertisement
Guest User

Untitled

a guest
May 28th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. <?php
  2.  
  3. define( "MYSQL_DEBUG", true );
  4.  
  5. // Main MySQL class
  6.  
  7. class MySQL
  8. {
  9.  
  10.     var $host = "x";
  11.     var $user = "x";
  12.     var $pass = "x";
  13.     var $database = "x";
  14.    
  15.     var $connection;
  16.    
  17.     function OpenConnection()
  18.     {
  19.    
  20.         $conn = mysql_connect( $this -> host, $this -> user, $this -> pass );
  21.        
  22.         if( !$conn || !mysql_select_db( $this -> database, $conn ) )
  23.         {
  24.        
  25.             if( MYSQL_DEBUG )
  26.             {
  27.            
  28.                 die( mysql_error() );
  29.            
  30.             }
  31.            
  32.             exit();
  33.        
  34.         }
  35.         else
  36.         {
  37.        
  38.             mysql_select_db( $this -> database );
  39.        
  40.         }
  41.        
  42.         $this -> connection = $conn;
  43.    
  44.     }
  45.    
  46.     function CloseConnection()
  47.     {
  48.    
  49.         if( !empty( $this -> conn ) )
  50.         {
  51.        
  52.             mysql_close( $this -> connection );
  53.        
  54.         }
  55.    
  56.     }
  57.    
  58.     function RunQuery( $sql )
  59.     {
  60.    
  61.         $query = mysql_query( $sql, $this -> connection );
  62.        
  63.         if( !$query )
  64.         {
  65.        
  66.             if( MYSQL_DEBUG )
  67.             {
  68.            
  69.                 die( "Error: " . mysql_error() );
  70.            
  71.             }
  72.            
  73.             return "";
  74.        
  75.         }
  76.        
  77.         return $query;
  78.    
  79.     }
  80.    
  81.     function Escape( $str )
  82.     {
  83.    
  84.         $str = mysql_real_escape_string( $str, $this -> connection );
  85.         $str = trim( str );
  86.        
  87.         return $str;
  88.    
  89.     }
  90.  
  91. }
  92. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement