18 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
32 function XoopsDatabaseFactory()
46 static function &getDatabaseConnection()
49 if (!isset($instance)) {
50 if (file_exists(
$file = XOOPS_ROOT_PATH .
'/class/database/' .
XOOPS_DB_TYPE .
'database.php')) {
53 if (!defined(
'XOOPS_DB_PROXY')) {
54 $class =
'Xoops' . ucfirst(XOOPS_DB_TYPE) .
'DatabaseSafe';
56 $class =
'Xoops' . ucfirst(XOOPS_DB_TYPE) .
'DatabaseProxy';
60 $xoopsPreload->triggerEvent(
'core.class.database.databasefactory.connection', array(&$class));
62 $instance =
new $class();
65 if (!$instance->connect()) {
66 trigger_error(
'notrace:Unable to connect to database', E_USER_ERROR);
69 trigger_error(
'notrace:Failed to load database of type: ' . XOOPS_DB_TYPE .
' in file: ' . __FILE__ .
' at line ' . __LINE__, E_USER_WARNING);
83 static function getDatabase()
86 if (!isset($database)) {
87 if (file_exists(
$file = XOOPS_ROOT_PATH .
'/class/database/' .
XOOPS_DB_TYPE .
'database.php')) {
89 if (!defined(
'XOOPS_DB_PROXY')) {
90 $class =
'Xoops' . ucfirst(XOOPS_DB_TYPE) .
'DatabaseSafe';
92 $class =
'Xoops' . ucfirst(XOOPS_DB_TYPE) .
'DatabaseProxy';
95 $database =
new $class();
97 trigger_error(
'notrace:Failed to load database of type: ' . XOOPS_DB_TYPE .
' in file: ' . __FILE__ .
' at line ' . __LINE__, E_USER_WARNING);