daily pastebin goal
62%
SHARE
TWEET

Untitled

a guest Aug 14th, 2016 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Class dbConnection {
  2.  
  3.     public $CONN;
  4.     private $dbservername, $dbusername, $dbpassword, $dbname;
  5.  
  6.     public function __construct() {
  7.  
  8.         $this->dbservername = "localhost";
  9.         $this->dbusername = "dbroot";
  10.         $this->dbpassword = "pass";
  11.         $this->dbname = "test";
  12.         $this->open(); //open the connection on instantization
  13.     }
  14.  
  15.     public function open() {
  16.  
  17.     // Create connection
  18.         $this->CONN = new mysqli($this->dbservername, $this->dbusername, $this->dbpassword, $this->dbname);
  19.  
  20.         // Check connection
  21.         if ($this->CONN->connect_error) {
  22.             die("Connection failed: " . $CONN->connect_error);
  23.  
  24.         }
  25.  
  26.     }
  27.  
  28.     public function prepare($query) {
  29.     //prepare the data
  30.         return $this->CONN->prepare($query);
  31.  
  32.     }
  33.  
  34.     public function close() {
  35.     //close the connection
  36.         $this->CONN->close();
  37.  
  38.     }
  39.  
  40. }
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