queryCol('SHOW TABLES'); if ($TABLES) foreach ($TABLES as $TABLE) { $tblName = 'tbl'.preg_replace("/^$prefix/", '', $TABLE); $DB->$tblName = $TABLE; } return true; } function &getInstance() { if (!isset($GLOBALS['skDB']) || !is_object($GLOBALS['skDB']) ) { require_once('MDB2.php'); $opt = array( 'portability' => MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL, 'portability' => MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL, ); if(defined('DEBUG') && DEBUG && defined('DEBUG_DUMP_SQL') && DEBUG_DUMP_SQL){ $opt['debug'] = true; $opt['debug_handler'] = 'S_db2_debug_dump_query'; } $GLOBALS['skDB'] =& MDB2::factory(DB_DSN, $opt); $GLOBALS['skDB']->setFetchMode(MDB2_FETCHMODE_ASSOC); S_db2::initTables($GLOBALS['skDB'], DB_PREFIX); global $__CONFIG; if(isset($__CONFIG['DB_STARTUP_CODE'])){ $sql = $__CONFIG['DB_STARTUP_CODE']; if(is_array($sql)){ foreach($sql as $line){ if(isset($line) && is_string($line) && $line != '') $GLOBALS['skDB']->exec($line); } } elseif(is_string($sql) && ($sql != '')){ $GLOBALS['skDB']->exec($sql); } } } return $GLOBALS['skDB']; } } if (!class_exists('S_db')) { class S_db extends S_db2 { } } $SQL_DebugQueryIndex = 1; function S_db2_debug_dump_query($object, $scope, $message, $context) { global $SQL_DebugQueryIndex; debugLog($scope . ' ('.($SQL_DebugQueryIndex++).'): ' .$message); }