Advertisement
Guest User

Untitled

a guest
Sep 11th, 2015
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.76 KB | None | 0 0
  1. final class DatabaseManager{
  2.  
  3.     private $hostname;
  4.     private $username;
  5.     private $password;
  6.     private $database;
  7.     private $active_record = "true";
  8.     private $active_group = "default";
  9.     private $dbdriver = "mysqli";
  10.     private $dbprefix = "";
  11.     private $pconnect = false;
  12.     private $db_debug = true;
  13.     private $cache_on = TRUE;
  14.     private $cachedir = "";
  15.     private $char_set = "latin1";
  16.     private $dbcollat = "latin1_swedish_ci";
  17.     private $cipher;
  18.    
  19.     private static $instance;
  20.  
  21.     protected function __construct($hostname,$username,$database){
  22.  
  23.         $this->setCipher(Cipher::getInstance());
  24.  
  25.         $this->setHostname($hostname);
  26.         $this->setUsername($username);
  27.         $this->setDatabase($database);        
  28.     }
  29.  
  30.     public static function initDatabase($hostname = null,$username = null,$database = null,$force_load = false){
  31.         if(self::$instance === null OR $force_load == true){
  32.             self::$instance = new self($hostname,$username,$database);
  33.         }
  34.  
  35.         return self::$instance;
  36.     }
  37.  
  38.     public function &exportConfigCI(){
  39.         //$config = get_object_vars($this); it don't return by ref
  40.         $config_ci = array();
  41.        
  42.         //foreach($config as $i=>$c){
  43.         //    $config_ci[$this->getActiveGroup()][$i] = $c;
  44.         //}
  45.  
  46.         $config_ci[$this->getActiveGroup()]['username'] = &$this->getUsername();
  47.         $config_ci[$this->getActiveGroup()]['password'] = &$this->getPassword();
  48.     //the same to all attribs
  49.                        
  50.         return $config_ci;
  51.     }
  52.  
  53.     public function &getUsername(){
  54.        return $this->username;
  55.     }
  56.  
  57.     public function &getPassword(){
  58.        return $this->password;
  59.     }
  60.  
  61.   //the same to all gets
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement