Pass the database object to the schema object

This commit is contained in:
markjcrane
2025-11-01 21:34:03 -06:00
parent 97af53b810
commit a90a4e6212
5 changed files with 15 additions and 17 deletions
+1 -1
View File
@@ -130,7 +130,7 @@
//load an array of the database schema and compare it with the active database //load an array of the database schema and compare it with the active database
if (!empty($action["upgrade_schema"]) && permission_exists("upgrade_schema")) { if (!empty($action["upgrade_schema"]) && permission_exists("upgrade_schema")) {
$obj = new schema(); $obj = new schema(['database' => $database]);
if (isset($action["data_types"]) && $action["data_types"] == 'true') { if (isset($action["data_types"]) && $action["data_types"] == 'true') {
$obj->data_types = true; $obj->data_types = true;
} }
+8 -9
View File
@@ -172,6 +172,9 @@
} }
} }
//initiliaze the schema object
$schema = new schema(['database' => $database]);
//use upgrade language file //use upgrade language file
$language = new text; $language = new text;
$text = $language->get(null, 'core/upgrade'); $text = $language->get(null, 'core/upgrade');
@@ -230,11 +233,10 @@
} }
//get the database schema put it into an array then compare and update the database as needed. //get the database schema put it into an array then compare and update the database as needed.
$obj = new schema;
if (isset($argv[2]) && $argv[2] == 'data_types') { if (isset($argv[2]) && $argv[2] == 'data_types') {
$obj->data_types = true; $schema->data_types = true;
} }
$response = $obj->schema($format ?? ''); $response = $schema->schema($format ?? '');
if ($display_type === 'text') { if ($display_type === 'text') {
foreach(explode("\n", $response) as $row) { foreach(explode("\n", $response) as $row) {
echo " ".trim($row)."\n"; echo " ".trim($row)."\n";
@@ -250,9 +252,8 @@
} }
//get the database schema put it into an array then compare and update the database as needed. //get the database schema put it into an array then compare and update the database as needed.
$obj = new schema; $schema->data_types = true;
$obj->data_types = true; $response = $schema->schema($format ?? '');
$response = $obj->schema($format ?? '');
if ($display_type === 'text') { if ($display_type === 'text') {
foreach(explode("\n", $response) as $row) { foreach(explode("\n", $response) as $row) {
echo " ".trim($row)."\n"; echo " ".trim($row)."\n";
@@ -323,7 +324,6 @@
// upgrade application defaults // upgrade application defaults
$domain = new domains; $domain = new domains;
$domain->display_type = $display_type;
$domain->upgrade(); $domain->upgrade();
} }
@@ -439,8 +439,7 @@
} }
//Update the table and field structure. //Update the table and field structure.
$obj = new schema; $response = $schema->schema("text");
$response = $obj->schema("text");
if ($display_type === 'text') { if ($display_type === 'text') {
foreach(explode("\n", $response) as $row) { foreach(explode("\n", $response) as $row) {
echo " ".trim($row)."\n"; echo " ".trim($row)."\n";
+1 -2
View File
@@ -316,7 +316,6 @@ function do_upgrade_code_submodules() {
*/ */
function do_upgrade_domains() { function do_upgrade_domains() {
$domain = new domains; $domain = new domains;
$domain->display_type = 'text';
$domain->upgrade(); $domain->upgrade();
} }
@@ -325,7 +324,7 @@ function do_upgrade_domains() {
*/ */
function do_upgrade_schema(bool $data_types = false) { function do_upgrade_schema(bool $data_types = false) {
//get the database schema put it into an array then compare and update the database as needed. //get the database schema put it into an array then compare and update the database as needed.
$obj = new schema; $obj = new schema();
$obj->data_types = $data_types; $obj->data_types = $data_types;
echo $obj->schema('text'); echo $obj->schema('text');
} }
+1 -1
View File
@@ -59,7 +59,7 @@
$text = $language->get(); $text = $language->get();
//get the database schema put it into an array then compare and update the database as needed. //get the database schema put it into an array then compare and update the database as needed.
$obj = new schema; $obj = new schema(['database' => $database]);
if (isset($argv[1]) && $argv[1] == 'data_types') { if (isset($argv[1]) && $argv[1] == 'data_types') {
$obj->data_types = true; $obj->data_types = true;
} }
+4 -4
View File
@@ -36,7 +36,7 @@
public $data_types; public $data_types;
//class constructor //class constructor
public function __construct($setting_array) { public function __construct($setting_array = []) {
//includes files //includes files
require dirname(__DIR__, 2) . "/resources/require.php"; require dirname(__DIR__, 2) . "/resources/require.php";
@@ -879,8 +879,8 @@
} }
//example use //example use
//$obj = new schema; //$schema = new schema();
//$obj->db_type = $db_type; //$schema->db_type = $db_type;
//$obj->schema(); //$schema->schema();
//$result_array = $schema->obj['sql']; //$result_array = $schema->obj['sql'];
//print_r($result_array); //print_r($result_array);