daily pastebin goal
70%
SHARE
TWEET

Untitled

a guest May 31st, 2017 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. define("T_OBJECT", "object");
  3. define("T_ARRAY", "array");
  4. define("T_ASSOC", "assoc");
  5.  
  6. class CloudSQL
  7. {
  8.     private $host, $username, $password, $database;    
  9.  
  10.     public function __construct($host, $username, $password, $database)
  11.     {
  12.         $this->username = $username;
  13.         $this->password = $password;
  14.         $this->host = $host;
  15.         $this->database = $database;   
  16.            
  17.         $SQLServer = @mysql_connect($this->host, $this->username, $this->password);
  18.         @mysql_select_db($this->database, $SQLServer);
  19.     }  
  20.  
  21.     public static function query($query)
  22.     {
  23.         return mysql_query($query);
  24.     }
  25.  
  26.     public static function fetch($resultQuery, $type = "object")
  27.     {
  28.         if(isset($type))
  29.         {
  30.             switch($type)
  31.             {
  32.                 case "object":
  33.                     return mysql_fetch_object($resultQuery);
  34.                     break;
  35.                 case "array":
  36.                     return mysql_fetch_array($resultQuery);
  37.                     break;
  38.                 case "assoc":
  39.                     return mysql_fetch_assoc($resultQuery);
  40.                     break;
  41.                 default:
  42.                     return mysql_fetch_object($resultQuery);
  43.             }
  44.         }
  45.         else
  46.         {                                                                      
  47.             return mysql_fetch_object($resultQuery);
  48.         }
  49.     }
  50.  
  51.     public static function counts($resultCount)
  52.     {
  53.         return mysql_num_rows($resultCount);
  54.     }
  55.  
  56.     public static function error()
  57.     {
  58.         return mysql_error();
  59.     }
  60.  
  61.     public static function errno()
  62.     {
  63.         if(mysql_errno())
  64.         {
  65.             return true;
  66.         }
  67.         else
  68.         {
  69.             return false;
  70.         }
  71.     }
  72.  
  73. }
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