Exemplo n.º 1
0
 /**
  * Instantiate a database driver object and return it (Factory)
  * @return object
  * @throws Exception
  */
 public static function getInstance()
 {
     if (!is_object(self::$objInstance)) {
         $strClass = 'DB_' . ucfirst(strtolower($GLOBALS['TL_CONFIG']['dbDriver']));
         $strFile = sprintf('%s/system/drivers/%s.php', TL_ROOT, $strClass);
         if (!file_exists($strFile)) {
             throw new Exception(sprintf('Could not load database driver %s', $strClass));
         }
         include_once $strFile;
         define('DB_DRIVER', $strClass);
         self::$objInstance = new $strClass();
     }
     return self::$objInstance;
 }
Exemplo n.º 2
0
 public static function GetInstance($database_host, $database_name, $database_username, $database_password, $db_driver = "", $force_encoding = false)
 {
     if (!self::$objInstance) {
         self::$objInstance = new Database($database_host, $database_name, $database_username, $database_password, $db_driver, $force_encoding);
     }
     return self::$objInstance;
 }