DB IO clean up work

Move methods around so they are grouped more logically. This is for a
future split out for function groups into sub classes to the main DB IO
class (private classes).

Also add a global variable $DB_CONFIG because setting this as constant
prevents us from override the debug config.
But for this add a third parameter to set debug flag override
This commit is contained in:
Clemens Schwaighofer
2022-02-24 13:25:11 +09:00
parent de1cdfdd40
commit f2c0ba737a
3 changed files with 511 additions and 463 deletions

View File

@@ -6,14 +6,8 @@
declare(strict_types=1);
$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations
$DEBUG_ALL = true;
$PRINT_ALL = true;
$DB_DEBUG = true;
if ($DEBUG_ALL) {
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
}
// turn on all error reporting
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
ob_start();
@@ -23,10 +17,6 @@ define('USE_DATABASE', true);
require 'config.php';
// override ECHO ALL FALSE
$ECHO_ALL = true;
// set session name
if (!defined('SET_SESSION_NAME')) {
define('SET_SESSION_NAME', EDIT_SESSION_NAME);
}
// define log file id
$LOG_FILE_ID = 'classTest-db';
ob_end_flush();
@@ -45,17 +35,13 @@ $log = new CoreLibs\Debug\Logging([
'echo_all' => $ECHO_ALL ?? false,
'print_all' => $PRINT_ALL ?? false,
]);
$basic = new CoreLibs\Basic($log);
// $basic = new CoreLibs\Basic($log, EDIT_SESSION_NAME);
//start session
\CoreLibs\Create\Session::startSession(EDIT_SESSION_NAME);
// db connection and attach logger
$db = new CoreLibs\Admin\Backend(DB_CONFIG, $log);
$db->log->debug('START', '=============================>');
// NEXT STEP
// $basic = new CoreLibs\Basic();
// change __construct
// add object $logger
// add $this->log = $logger;
// $db = new CoreLibs\DB\IO(DB_CONFIG, $basic->log);
print "<html><head><title>TEST CLASS: DB</title><head>";
print "<body>";
print '<div><a href="class_test.php">Class Test Master</a></div>';

View File

@@ -246,6 +246,8 @@ if (
// define the db config set name, the db config and the db schema
define('DB_CONFIG_NAME', $SITE_CONFIG[HOST_NAME]['db_host']);
define('DB_CONFIG', isset($DB_CONFIG[DB_CONFIG_NAME]) ? $DB_CONFIG[DB_CONFIG_NAME] : []);
// because we can't change constant, but we want to for db debug flag
$GLOBALS['DB_CONIFG'] = DB_CONFIG;
// define('DB_CONFIG_TARGET', SITE_CONFIG[$HOST_NAME]['db_host_target']);
// define('DB_CONFIG_OTHER', SITE_CONFIG[$HOST_NAME]['db_host_other']);
// override for login and global schemas

File diff suppressed because it is too large Load Diff