phpbego

Koneksi

Jul 18th, 2014
2,884
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2. /*
  3.  * http://phpbego.wordpress.com
  4.  * Juli 2014
  5.  */
  6.  
  7. class Koneksi {
  8.  
  9.     private $host = "localhost";
  10.     private $user = "root";
  11.     private $pass = "faiz";
  12.     private $dbname = "db_multilevel_login";
  13.     private $db_connection = null;
  14.    
  15.     public function getConnection() {
  16.         $this->db_connection = new mysqli($this->host, $this->user, $this->pass, $this->dbname);   
  17.         if ($this->db_connection->connect_errno) {
  18.             echo "Failed to connect to Database: (" . $this->db_connection->connect_errno . ") " . $this->db_connection->connect_error;
  19.         } else {
  20.             return $this->db_connection;
  21.         }
  22.     }
  23.    
  24. }
Advertisement
Add Comment
Please, Sign In to add comment