Guest User

Untitled

a guest
Dec 25th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. <?php
  2. ini_set('mysql.connect_timeout', 5);
  3.  
  4. class SQL {
  5.     function __construct($config = "config.ini") {
  6.         $this->config = parse_ini_file($config);
  7.         $this->host = $this->config['Host'];
  8.         $this->user = $this->config['User'];
  9.         $this->pass = $this->config['Pass'];
  10.         $this->dbname = $this->config['DBName'];
  11.         $this->table = $this->config['Table'];
  12.     }
  13.     public function connect() {
  14.         mysql_connect($this->host, $this->user, $this->pass) or die("[CRITICAL]Could not establish SQL connection.\n");
  15.         mysql_select_db($this->dbname); or die("[CRITICAL]Could not select database.\n");
  16.     }
  17.    
  18.     public function query($sql) {
  19.         $query - mysql_query($sql);
  20.         if(!$query) echo "[WARNING]Erorr with MySQL Query (".mysql_error().")\n";
  21.         else echo "[MySQL]".$sql."\n";
  22.     }
  23.    
  24.     function __destruct() {
  25.         mysql_close();
  26.         echo("[MySQL] Connection Closed.\n");
  27.         die();
  28.     }
  29. }
  30. ?>
Add Comment
Please, Sign In to add comment