Advertisement
Guest User

Untitled

a guest
Jun 4th, 2016
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.73 KB | None | 0 0
  1. <?php
  2. require_once(DIR_LIB . "ChaveHash/Cipher.php");
  3. /**
  4.  * DatabaseManager Class
  5.  *
  6.  * Manage and exports the db attributes
  7.  *
  8.  * @author  Hugo Carvalho
  9.  * @category    Database
  10.  * @since       21-09-2015
  11.  */
  12.  
  13. final class DatabaseManager{
  14.  
  15.     private $hostname;
  16.     private $username;
  17.     private $password;
  18.     private $database;
  19.     private $active_record = "true";
  20.     private $active_group = "default";
  21.     private $dbdriver = "mysqli";
  22.     private $dbprefix = "";
  23.     private $pconnect = false;
  24.     private $db_debug = true;
  25.     private $cache_on = TRUE;
  26.     private $cachedir = "";
  27.     private $char_set = "latin1";
  28.     private $dbcollat = "latin1_swedish_ci";
  29.     private $cipher;
  30.    
  31.     private static $instance;
  32.  
  33.     protected function __construct($hostname,$username,$database){
  34.  
  35.         $this->setCipher(Cipher::getInstance());
  36.  
  37.         $this->setHostname($hostname);
  38.         $this->setUsername($username);
  39.         $this->setDatabase($database);        
  40.     }
  41.  
  42.     public static function initDatabase($hostname = null,$username = null,$database = null){
  43.         if(self::$instance === null){
  44.             self::$instance = new self($hostname,$username,$database);
  45.         }
  46.  
  47.         return self::$instance;
  48.     }
  49.  
  50.     public function &exportConfigCI(){
  51.         $config = get_object_vars($this);
  52.         $config_ci = array();
  53.        
  54.         foreach($config as $i=>$c){
  55.            $config_ci[$this->getActiveGroup()][$i] = $c;
  56.         }
  57.        
  58.         unset($config_ci[$this->getActiveGroup()]['active_record']);
  59.         unset($config_ci[$this->getActiveGroup()]['active_group']);
  60.                        
  61.         return $config_ci;
  62.     }
  63.  
  64.     /**
  65.     * Gets and sets for all attributes
  66.     */
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement