<?php 


class Db{

  private $host = 'localhost';
  private $user = 'adeobjzb_rexcbt';
  private $pass = 'Isiah60:1-4';
  private $name = 'adeobjzb_rexcbt';
 
 private $_connection;
 private static $_dbinstance;

/* Made the constructor private, 
* to ensures that the class can only be instantiated 
* from within itself.
*/
 private function __construct()
  {
	  try{
    $this->_connection = new PDO("mysql:host={$this->host};
    dbname={$this->name}", $this->user,$this->pass,
    array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
	$this->_connection-> setAttribute( PDO::ATTR_PERSISTENT, true );
	$this->_connection-> setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
	  }
	  
	  catch(PDOException $e){
		  die( "Connection failed: " . $e-> getMessage() );
		  }
	
  }
 
 public static function getInstance(){
  if (is_null(self::$_dbinstance)){
   self::$_dbinstance= new Db();
  }
  return self::$_dbinstance;
 }
 /* Execute a SQL query and returns the results*/
 public function selectQuery($query){
  $rs=$this->_connection->query($query);
  return $rs; 
 }
 
 public function getConnection(){
	 return $this->_connection;
	 }
 
 
  public function DisConnect(){
	 return $this->_connection = "";
	 }
 
 
 
}





?>