Advertisement
LemmyNjaria

DbConnect

Mar 25th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.36 KB | None | 0 0
  1. <?php
  2.  
  3.     class DbConnect{
  4.  
  5.         private $con;
  6.  
  7.         function __construct(){
  8.  
  9.         }
  10.  
  11.         function connect(){
  12.             include_once dirname(__FILE__).'/Constants.php';
  13.             $this->con = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
  14.  
  15.             if(mysqli_connect_errno()){
  16.                 echo "Failed to connect with database".mysqli_connect_err();
  17.             }
  18.  
  19.             return $this->con;
  20.         }
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement