Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. <?php
  2. class MySQL
  3. {
  4.     private $con;
  5.     public function __contruct($host="localhost",$username="root",$password="")
  6.     {
  7.     $this->con = mysql_connect($host,$username,$password);
  8.     if (!$this->con)
  9.     {
  10.         die('Could not connect: ' . mysql_error());
  11.     }
  12.     }
  13.     public function chooseDB($db)
  14.     {
  15.     if($this->con)
  16.     {
  17.         mysql_select_db($db, $this->con);
  18.         return true;
  19.     }
  20.     else
  21.         return false;
  22.  
  23.     }
  24.     public function query($query)
  25.     {
  26.     if($this->con)
  27.         return mysql_query($query);
  28.     else
  29.         return false;
  30.     }
  31.     public function __destruct()
  32.     {
  33.     if($this->con)
  34.         mysql_close($this->con);
  35.     }
  36. }
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement