Guest User

Untitled

a guest
Jun 22nd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.17 KB | None | 0 0
  1. <?php
  2. require_once('system/class.mysql_config.php');
  3. class HRF_MySQLi extends mysql_config
  4. {
  5.     private $connection;
  6.     private static $m_pInstance;
  7.  
  8.     public $db_host;
  9.     public $db_user;
  10.     public $db_pass;
  11.     public $db_name;
  12.    
  13.     public function __construct()
  14.     {
  15.         echo "Constructor called<br />\n";
  16.         $this->db_host = $this->config_mysql_host;
  17.         $this->db_user = $this->config_mysql_user;
  18.         $this->db_pass = $this->config_mysql_pass;
  19.         $this->db_name = $this->config_mysql_name;
  20.     }
  21.    
  22.     public function makeConnection(){
  23.         //connectie maken
  24.         $this->connection = new mysqli($this->db_host,$this->db_user,$this->db_pass,$this->db_name);
  25.         if (mysqli_connect_errno()) {
  26.             printf("Kan niet connecteren met MySQL Server. Errorcode: %s <br />", mysqli_connect_error());
  27.             exit;
  28.         }
  29.        
  30.         //encoding op UTF-8 zetten
  31.         $this->connection->query("SET NAMES 'utf8'");
  32.     }
  33.    
  34.     public function getConnection(){
  35.         return $this->connection;
  36.     }
  37.    
  38.     public function closeConnection(){
  39.         $this->connection->close();
  40.     }
  41.    
  42.     public static function getInstance()
  43.     {
  44.         if (!self::$m_pInstance)
  45.         {
  46.             self::$m_pInstance = new HRF_MySQLi();
  47.         }
  48.  
  49.         return self::$m_pInstance;
  50.     }
  51. }
Add Comment
Please, Sign In to add comment