|
@@ -523,22 +523,9 @@ if (!class_exists('schema')) {
|
|
//check if table exists
|
|
//check if table exists
|
|
// SELECT TABLE_NAME FROM ALL_TABLES
|
|
// SELECT TABLE_NAME FROM ALL_TABLES
|
|
|
|
|
|
- //get the $apps array from the installed apps from the core and mod directories
|
|
|
|
- $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
|
|
|
|
- $x=0;
|
|
|
|
- foreach ($config_list as &$config_path) {
|
|
|
|
- try {
|
|
|
|
- include($config_path);
|
|
|
|
- }
|
|
|
|
- catch (Exception $e) {
|
|
|
|
- //echo 'Caught exception: ', $e->getMessage(), "\n";
|
|
|
|
- }
|
|
|
|
- $x++;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
//update the app db array add exists true or false
|
|
//update the app db array add exists true or false
|
|
$sql = '';
|
|
$sql = '';
|
|
- foreach ($apps as $x => &$app) {
|
|
|
|
|
|
+ foreach ($this->apps as $x => &$app) {
|
|
if (isset($app['db'])) foreach ($app['db'] as $y => &$row) {
|
|
if (isset($app['db'])) foreach ($app['db'] as $y => &$row) {
|
|
if (isset($row['table']['name'])) {
|
|
if (isset($row['table']['name'])) {
|
|
if (is_array($row['table']['name'])) {
|
|
if (is_array($row['table']['name'])) {
|
|
@@ -598,10 +585,9 @@ if (!class_exists('schema')) {
|
|
|
|
|
|
//prepare the variables
|
|
//prepare the variables
|
|
$sql_update = '';
|
|
$sql_update = '';
|
|
- $var_uuid = $_GET["id"] ?? '';
|
|
|
|
|
|
|
|
//add missing tables and fields
|
|
//add missing tables and fields
|
|
- foreach ($apps as $x => &$app) {
|
|
|
|
|
|
+ foreach ($this->apps as $x => &$app) {
|
|
if (isset($app['db'])) foreach ($app['db'] as $y => &$row) {
|
|
if (isset($app['db'])) foreach ($app['db'] as $y => &$row) {
|
|
if (is_array($row['table']['name'])) {
|
|
if (is_array($row['table']['name'])) {
|
|
$table_name = $row['table']['name']['text'];
|
|
$table_name = $row['table']['name']['text'];
|
|
@@ -623,7 +609,7 @@ if (!class_exists('schema')) {
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
$row['exists'] = "false";
|
|
$row['exists'] = "false";
|
|
- $sql_update .= $this->db_create_table($apps, $db_type, $row['table']['name']['text']);
|
|
|
|
|
|
+ $sql_update .= $this->db_create_table($this->apps, $db_type, $row['table']['name']['text']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -649,7 +635,7 @@ if (!class_exists('schema')) {
|
|
if (is_array($field['name'])) {
|
|
if (is_array($field['name'])) {
|
|
$field_name = $field['name']['text'];
|
|
$field_name = $field['name']['text'];
|
|
if (!$this->db_column_exists ($db_type, $db_name, $table_name, $field_name)) {
|
|
if (!$this->db_column_exists ($db_type, $db_name, $table_name, $field_name)) {
|
|
- $field['exists'] == "false";
|
|
|
|
|
|
+ $field['exists'] = "false";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
@@ -734,19 +720,18 @@ if (!class_exists('schema')) {
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- unset($column_array);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
//create table
|
|
//create table
|
|
if (!is_array($row['table']['name'])) {
|
|
if (!is_array($row['table']['name'])) {
|
|
- $sql_update .= $this->db_create_table($apps, $db_type, $row['table']['name']);
|
|
|
|
|
|
+ $sql_update .= $this->db_create_table($this->apps, $db_type, $row['table']['name']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//rebuild and populate the table
|
|
//rebuild and populate the table
|
|
- foreach ($apps as $x => &$app) {
|
|
|
|
|
|
+ foreach ($this->apps as $x => &$app) {
|
|
if (isset($app['db'])) foreach ($app['db'] as $y => &$row) {
|
|
if (isset($app['db'])) foreach ($app['db'] as $y => &$row) {
|
|
if (is_array($row['table']['name'])) {
|
|
if (is_array($row['table']['name'])) {
|
|
$table_name = $row['table']['name']['text'];
|
|
$table_name = $row['table']['name']['text'];
|
|
@@ -761,9 +746,9 @@ if (!class_exists('schema')) {
|
|
//rename the table
|
|
//rename the table
|
|
$sql_update .= "ALTER TABLE ".$table_name." RENAME TO tmp_".$table_name.";\n";
|
|
$sql_update .= "ALTER TABLE ".$table_name." RENAME TO tmp_".$table_name.";\n";
|
|
//create the table
|
|
//create the table
|
|
- $sql_update .= $this->db_create_table($apps, $db_type, $table_name);
|
|
|
|
|
|
+ $sql_update .= $this->db_create_table($this->apps, $db_type, $table_name);
|
|
//insert the data into the new table
|
|
//insert the data into the new table
|
|
- $sql_update .= $this->db_insert_into($apps, $db_type, $table_name);
|
|
|
|
|
|
+ $sql_update .= $this->db_insert_into($this->apps, $db_type, $table_name);
|
|
//drop the old table
|
|
//drop the old table
|
|
$sql_update .= "DROP TABLE tmp_".$table_name.";\n";
|
|
$sql_update .= "DROP TABLE tmp_".$table_name.";\n";
|
|
//commit the transaction
|
|
//commit the transaction
|
|
@@ -803,7 +788,7 @@ if (!class_exists('schema')) {
|
|
$response .= "<tr>\n";
|
|
$response .= "<tr>\n";
|
|
//build the html while looping through the app db array
|
|
//build the html while looping through the app db array
|
|
$sql = '';
|
|
$sql = '';
|
|
- foreach ($apps as &$app) {
|
|
|
|
|
|
+ foreach ($this->apps as &$app) {
|
|
if (isset($app['db'])) foreach ($app['db'] as $row) {
|
|
if (isset($app['db'])) foreach ($app['db'] as $row) {
|
|
if (is_array($row['table']['name'])) {
|
|
if (is_array($row['table']['name'])) {
|
|
$table_name = $row['table']['name']['text'];
|
|
$table_name = $row['table']['name']['text'];
|
|
@@ -858,7 +843,6 @@ if (!class_exists('schema')) {
|
|
$response .= "</tr>\n";
|
|
$response .= "</tr>\n";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- unset($column_array);
|
|
|
|
$response .= " </table>\n";
|
|
$response .= " </table>\n";
|
|
$response .= "</td>\n";
|
|
$response .= "</td>\n";
|
|
}
|
|
}
|
|
@@ -871,7 +855,6 @@ if (!class_exists('schema')) {
|
|
$response .= "</tr>\n";
|
|
$response .= "</tr>\n";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- unset ($prep_statement);
|
|
|
|
//end the list of tables
|
|
//end the list of tables
|
|
$response .= "</table>\n";
|
|
$response .= "</table>\n";
|
|
$response .= "<br />\n";
|
|
$response .= "<br />\n";
|
|
@@ -904,7 +887,7 @@ if (!class_exists('schema')) {
|
|
}
|
|
}
|
|
//$this->db->commit();
|
|
//$this->db->commit();
|
|
$response .= "\n";
|
|
$response .= "\n";
|
|
- unset ($file_contents, $sql_update, $sql);
|
|
|
|
|
|
+ unset ($sql_update, $sql);
|
|
}
|
|
}
|
|
|
|
|
|
//handle response
|
|
//handle response
|