XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
databasefactory.php
1<?php
13
15{
16 public function __construct()
17 {
18 }
19
25 public static function &getDatabaseConnection()
26 {
27 static $instance;
28 if (!isset($instance)) {
29 $file = XOOPS_ROOT_PATH.'/class/database/'.XOOPS_DB_TYPE.'database.php';
30 require_once $file;
31 /* begin DB Layer Trapping patch */
32 if (defined('XOOPS_DB_ALTERNATIVE') && class_exists(XOOPS_DB_ALTERNATIVE)) {
33 $class = XOOPS_DB_ALTERNATIVE;
34 } elseif (!defined('XOOPS_DB_PROXY')) {
35 $class = 'Xoops'.ucfirst(XOOPS_DB_TYPE).'DatabaseSafe';
36 } else {
37 $class = 'Xoops'.ucfirst(XOOPS_DB_TYPE).'DatabaseProxy';
38 }
39 $instance = new $class();
40 $instance->setLogger(XoopsLogger::instance());
41 $instance->setPrefix(XOOPS_DB_PREFIX);
42 if (!$instance->connect()) {
43 echo 'Unable to connect to the database.';
44 header('HTTP/1.1 503 Service Temporarily Unavailable');
45 trigger_error('Unable to connect to database', E_USER_ERROR);
46 }
47 }
48 return $instance;
49 }
50
59 public static function &getDatabase()
60 {
61 static $database;
62 if (!isset($database)) {
63 $file = XOOPS_ROOT_PATH.'/class/database/'.XOOPS_DB_TYPE.'database.php';
64 require_once $file;
65 if (!defined('XOOPS_DB_PROXY')) {
66 $class = 'Xoops'.ucfirst(XOOPS_DB_TYPE).'DatabaseSafe';
67 } else {
68 $class = 'Xoops'.ucfirst(XOOPS_DB_TYPE).'DatabaseProxy';
69 }
70 $database =new $class();
71 }
72 return $database;
73 }
74}
static & getDatabaseConnection()
static & instance()
Definition logger.php:45