Advertisement
Guest User

Untitled

a guest
May 27th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 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 = "127.0.0.1";
  11.     var $user = "root";
  12.     var $pass = "";
  13.     var $database = "cmb";
  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.             return;
  33.        
  34.         }
  35.         else
  36.         {
  37.        
  38.             mysql_select_db( $this->database );
  39.        
  40.         }
  41.    
  42.     }
  43.    
  44.     function CloseConnection()
  45.     {
  46.    
  47.         if( !empty( $this->conn ) )
  48.         {
  49.        
  50.             mysql_close( $this->conn );
  51.        
  52.         }
  53.    
  54.     }
  55.    
  56.     function RunQuery( $sql )
  57.    
  58.         if( empty( $this->conn ) )
  59.         {
  60.        
  61.             return;
  62.        
  63.         }
  64.        
  65.         $query = mysql_query( $sql, $this->conn );
  66.        
  67.         if( mysql_num_rows( $query ) > 1 )
  68.         {
  69.        
  70.             if( MYSQL_DEBUG )
  71.             {
  72.            
  73.                 die( mysql_error() );
  74.            
  75.             }
  76.            
  77.             return "";
  78.        
  79.         }
  80.        
  81.     }
  82.  
  83. }
  84. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement