Upgrade: Divides Upgrade Schema into separate processes. Complete translation forthcoming. (Still under construction...)

This commit is contained in:
Nate Jones
2014-07-10 06:05:22 +00:00
parent d9f6d900e4
commit 8bd5b7112b
7 changed files with 377 additions and 101 deletions

View File

@@ -1,12 +1,12 @@
<?php
//application details
$apps[$x]['name'] = "Upgrade Schema";
$apps[$x]['name'] = "Upgrade";
$apps[$x]['uuid'] = "8b1d7eb5-1009-052c-e1a8-d1f4887a3f5c";
$apps[$x]['category'] = "Core";
$apps[$x]['subcategory'] = "";
$apps[$x]['version'] = "";
$apps[$x]['url'] = "http://www.fusionpbx.com";
$apps[$x]['description']['en-us'] = "Upgrade the database schema.";
$apps[$x]['description']['en-us'] = "Update or restore various system settings.";
$apps[$x]['description']['es-cl'] = "Actualiza el esquema de la base de datos";
$apps[$x]['description']['de-de'] = "";
$apps[$x]['description']['de-ch'] = "";
@@ -18,12 +18,12 @@
$apps[$x]['description']['pt-br'] = "";
//menu details
$apps[$x]['menu'][0]['title']['en-us'] = "Upgrade Schema";
$apps[$x]['menu'][0]['title']['es-cl'] = "Actualizar Esquema";
$apps[$x]['menu'][0]['title']['en-us'] = "Upgrade";
$apps[$x]['menu'][0]['title']['es-cl'] = "Actualizar";
$apps[$x]['menu'][0]['title']['de-de'] = "";
$apps[$x]['menu'][0]['title']['de-ch'] = "";
$apps[$x]['menu'][0]['title']['de-at'] = "";
$apps[$x]['menu'][0]['title']['fr-fr'] = "MàJ BDD";
$apps[$x]['menu'][0]['title']['fr-fr'] = "Mise à jour";
$apps[$x]['menu'][0]['title']['fr-ca'] = "";
$apps[$x]['menu'][0]['title']['fr-ch'] = "";
$apps[$x]['menu'][0]['title']['pt-pt'] = "Actualizar BD";
@@ -31,15 +31,27 @@
$apps[$x]['menu'][0]['uuid'] = "8c826e92-be3c-0944-669a-24e5b915d562";
$apps[$x]['menu'][0]['parent_uuid'] = "594d99c5-6128-9c88-ca35-4b33392cec0f";
$apps[$x]['menu'][0]['category'] = "internal";
$apps[$x]['menu'][0]['path'] = "/core/upgrade/upgrade_schema.php";
$apps[$x]['menu'][0]['path'] = "/core/upgrade/index.php";
$apps[$x]['menu'][0]['groups'][] = "superadmin";
//permission details
$apps[$x]['permissions'][0]['name'] = "upgrade_schema";
$apps[$x]['permissions'][0]['menu']['uuid'] = "8c826e92-be3c-0944-669a-24e5b915d562";
$apps[$x]['permissions'][0]['groups'][] = "superadmin";
$apps[$x]['permissions'][1]['name'] = "upgrade_svn";
$y = 0;
$apps[$x]['permissions'][$y]['name'] = "upgrade_svn";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "71051909-81ff-4301-9997-52b11206b3a6";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "upgrade_schema";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "8c826e92-be3c-0944-669a-24e5b915d562";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "upgrade_domains";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "e7bb1296-3141-48c9-a95a-82d2768d0ae4";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "upgrade_datatypes";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "9c82d494-c248-4f74-a82b-2af15064d6fc";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
//schema details
$y = 0; //table array index

View File

@@ -5,11 +5,26 @@
$text['title-upgrade_schema']['pt-pt'] = "Actualizar Esquema de Base de Dados";
$text['title-upgrade_schema']['fr-fr'] = "Mise à jour du Schéma";
$text['title-upgrade']['en-us'] = "Upgrade";
$text['title-upgrade']['es-cl'] = "Actualizar";
$text['title-upgrade']['pt-pt'] = "Actualizar";
$text['title-upgrade']['fr-fr'] = "Mise à jour";
$text['header-upgrade_schema_results']['en-us'] = "Upgrade Schema Results";
$text['header-upgrade_schema_results']['es-cl'] = "Actualiza Esquema Resultados";
$text['header-upgrade_schema_results']['pt-pt'] = "Resultados Atualização do Esquema";
$text['header-upgrade_schema_results']['fr-fr'] = "Résultats Mise à Jour du Schéma";
$text['header-database_type']['en-us'] = "Database Type";
$text['header-database_type']['es-cl'] = "Tipo de base de datos";
$text['header-database_type']['pt-pt'] = "Tipo de Base de Dados";
$text['header-database_type']['fr-fr'] = "Type de base de données";
$text['header-upgrade']['en-us'] = "Upgrade";
$text['header-upgrade']['es-cl'] = "Actualizar";
$text['header-upgrade']['pt-pt'] = "Actualizar";
$text['header-upgrade']['fr-fr'] = "Mise à jour";
$text['header-message']['en-us'] = "Message";
$text['header-message']['es-cl'] = "Mensaje";
$text['header-message']['pt-pt'] = "Mensagem";

236
core/upgrade/index.php Normal file
View File

@@ -0,0 +1,236 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
set_time_limit(600); //sec (10 min)
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check the permission
if (
!permission_exists('upgrade_svn') &&
!permission_exists('upgrade_schema') &&
!permission_exists('upgrade_domains') &&
!permission_exists('upgrade_datatypes') &&
!permission_exists('menu_restore') &&
!permission_exists('group_edit')
) {
echo "access denied";
exit;
}
if (sizeof($_POST) > 0) {
$do = $_POST['do'];
// run svn update
if ($do["svn"] && permission_exists("upgrade_svn")) {
$response_message[] = "SVN Updated";
}
// load the default database into memory and compare it with the active database
if ($do["schema"] && permission_exists("upgrade_schema")) {
$included = true;
$response_output = "return";
$response_format = "html";
require_once "core/upgrade/upgrade_schema.php";
if ($response_upgrade_schema != '') {
$_SESSION["response_upgrade_schema"] = $response_upgrade_schema;
}
unset($apps);
$response_message[] = "Schema Upgraded";
}
// upgrade the domains
if ($do["domains"] && permission_exists("upgrade_domains")) {
$included = true;
$domain_language_code = $_SESSION['domain']['language']['code'];
require_once "core/upgrade/upgrade_domains.php";
$_SESSION['domain']['language']['code'] = $domain_language_code;
unset($domain_language_code);
$response_message[] = "Domain(s) Upgraded";
}
// syncronize data types
if ($do["datatypes"] && permission_exists("upgrade_datatypes")) {
$response_message[] = "Data Types Syncronized";
}
// restore defaults of the selected menu
if ($do["menu"] && permission_exists("menu_restore")) {
$sel_menu = explode('|', $_POST["sel_menu"]);
$menu_uuid = $sel_menu[0];
$menu_language = $sel_menu[1];
$included = true;
require_once("core/menu/menu_restore_default.php");
unset($sel_menu);
$response_message[] = "Menu Restored";
}
// restore default permissions
if ($do["permissions"] && permission_exists("group_edit")) {
$included = true;
require_once("core/users/permissions_default.php");
$response_message[] = "Permissions Restored";
}
$_SESSION["message"] = implode("<br />", $response_message);
header("Location: ".PROJECT_PATH."/core/upgrade/index.php");
exit;
} // if
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
require_once "resources/header.php";
$document['title'] = $text['title-upgrade'];
//set defaults
$display_type = 'html';
echo "<b>".$text['header-upgrade']."</b><br>";
echo "Select the upgrade/update/restore actions below you wish to perform.";
echo "<br><br><br>";
echo "<form name='frm' method='post' action=''>\n";
echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
if (permission_exists("upgrade_svn")) {
echo "<tr>\n";
echo " <td width='30%' class='vncell'>\n";
echo " SVN Update";
echo " </td>\n";
echo " <td width='70%' class='vtable' style='height: 50px;'>\n";
echo " <input type='checkbox' class='formfld' name='do[svn]' id='do_svn' value='1'>";
echo " <br />\n";
echo " </td>\n";
echo "</tr>\n";
}
if (permission_exists("upgrade_schema")) {
echo "<tr>\n";
echo " <td width='30%' class='vncell'>\n";
echo " Upgrade Schema";
echo " </td>\n";
echo " <td width='70%' class='vtable' style='height: 50px;'>\n";
echo " <input type='checkbox' class='formfld' name='do[schema]' id='do_schema' value='1'>";
echo " <br />\n";
echo " </td>\n";
echo "</tr>\n";
}
if (permission_exists("upgrade_domains")) {
echo "<tr>\n";
echo " <td width='30%' class='vncell'>\n";
echo " Upgrade Domain(s)";
echo " </td>\n";
echo " <td width='70%' class='vtable' style='height: 50px;'>\n";
echo " <input type='checkbox' class='formfld' name='do[domains]' id='do_domains' value='1'>";
echo " <br />\n";
echo " </td>\n";
echo "</tr>\n";
}
if (permission_exists("upgrade_datatypes")) {
echo "<tr>\n";
echo " <td width='30%' class='vncell'>\n";
echo " Syncronize Data Types";
echo " </td>\n";
echo " <td width='70%' class='vtable' style='height: 50px;'>\n";
echo " <input type='checkbox' class='formfld' name='do[datatypes]' id='do_datatypes' value='1'>";
echo " <br />\n";
echo " </td>\n";
echo "</tr>\n";
}
if (permission_exists("menu_restore")) {
echo "<tr>\n";
echo " <td width='30%' class='vncell'>\n";
echo " Restore Menu Defaults";
echo " </td>\n";
echo " <td width='70%' class='vtable' style='height: 50px;'>\n";
echo " <table cellpadding='0' cellspacing='0' border='0'>";
echo " <tr><td>";
echo " <input type='checkbox' class='formfld' name='do[menu]' id='do_menu' value='1' onclick=\"$('#sel_menu').fadeToggle('fast');\">";
echo " </td><td>";
echo " <select name='sel_menu' id='sel_menu' class='formfld' style='display: none; margin-left: 15px;'>\n";
$sql = "select * from v_menus ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
echo "<option value='".$row["menu_uuid"]."|".$row["menu_language"]."'>".$row["menu_name"]."</option>\n";
}
unset ($sql, $result, $prep_statement);
echo " </select>\n";
echo " </td></tr>";
echo " </table>";
echo " </td>\n";
echo "</tr>\n";
}
if (permission_exists("group_edit")) {
echo "<tr>\n";
echo " <td width='30%' class='vncell'>\n";
echo " Restore Permission Defaults";
echo " </td>\n";
echo " <td width='70%' class='vtable' style='height: 50px;'>\n";
echo " <input type='checkbox' class='formfld' name='do[permissions]' id='do_permissions' value='1'>";
echo " <br />\n";
echo " </td>\n";
echo "</tr>\n";
}
echo "<tr>\n";
echo " <td colspan='2' style='text-align: right;'>\n";
echo " <input type='submit' class='btn' value='Execute'>\n";
echo " </td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</form>\n";
// output result of upgrade schema
if ($_SESSION["response_upgrade_schema"] != '') {
echo "<br /><br /><br />";
echo "<b>".$text['header-upgrade_schema_results']."</b>";
echo "<br /><br />";
echo $_SESSION["response_upgrade_schema"];
unset($_SESSION["response_upgrade_schema"]);
}
require_once "resources/footer.php";
?>

View File

@@ -32,7 +32,7 @@
set_include_path($document_root);
require_once "resources/require.php";
$_SERVER["DOCUMENT_ROOT"] = $document_root;
$display_type = 'text'; //html, text
$response_format = 'text'; //html, text
//add multi-lingual support
require_once "app_languages.php";
@@ -61,16 +61,16 @@
}
//set the default
if (!isset($display_results)) {
$display_results = false;
if (!isset($response_output)) {
$response_output = "echo";
}
//include the header
if ($display_results) {
if ($response_output == "echo") {
require_once "resources/header.php";
}
if ($display_type == 'text') {
if ($response_format == 'text') {
echo "\n";
echo $text['label-upgrade']."\n";
echo "-----------------------------------------\n";
@@ -82,7 +82,7 @@ if ($display_type == 'text') {
require_once "core/upgrade/upgrade_schema.php";
//show the content
if ($display_type == 'html') {
if ($response_format == 'html') {
echo "<div align='center'>\n";
echo "<table width='40%'>\n";
echo "<tr>\n";
@@ -102,12 +102,12 @@ if ($display_type == 'text') {
echo "<br />\n";
echo "<br />\n";
}
elseif ($display_type == 'text') {
elseif ($response_format == 'text') {
echo "\n";
}
//include the footer
if ($display_results) {
if ($response_output == "echo") {
require_once "resources/footer.php";
}
?>

View File

@@ -24,6 +24,9 @@
Mark J Crane <markjcrane@fusionpbx.com>
*/
// set included, if not
if (!isset($included)) { $included = false; }
//check the permission
if(defined('STDIN')) {
$document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]);
@@ -34,7 +37,7 @@
$_SERVER["DOCUMENT_ROOT"] = $document_root;
$display_type = 'text'; //html, text
}
else {
else if (!$included) {
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";

View File

@@ -24,6 +24,10 @@
Mark J Crane <markjcrane@fusionpbx.com>
*/
// set included, if not
if (!isset($included)) { $included = false; }
//check the permission
if(defined('STDIN')) {
$document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]);
@@ -32,15 +36,9 @@
set_include_path($document_root);
require_once "resources/require.php";
$_SERVER["DOCUMENT_ROOT"] = $document_root;
$display_type = 'text'; //html, text
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
$response_format = 'text'; //html, text
}
else {
else if (!$included) {
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
@@ -52,35 +50,33 @@
exit;
}
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
require_once "resources/header.php";
$document['title'] = $text['title-upgrade_schema'];
$display_type = 'html'; //html, text
$response_format = 'html'; //html, text
}
//set the default
if (!isset($display_results)) {
$display_results = true;
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
//set the default
if (!isset($response_output)) {
$response_output = "echo";
}
//load the default database into memory and compare it with the active database
require_once "resources/schema.php";
db_upgrade_schema ($db, $db_type, $db_name, $display_results);
$response_upgrade_schema = db_upgrade_schema($db, $db_type, $db_name, $response_output);
unset($apps);
//upgrade the domains
$domain_language_code = $_SESSION['domain']['language']['code'];
require_once "core/upgrade/upgrade_domains.php";
$_SESSION['domain']['language']['code'] = $domain_language_code;
unset($domain_language_code);
if ($display_results && $display_type == "html") {
if (!$included && $response_output == 'echo' && $response_format == 'html') {
echo "<br />\n";
echo "<br />\n";
require_once "resources/footer.php";

View File

@@ -271,9 +271,9 @@ function db_insert_into ($apps, $db_type, $table) {
}
}
function db_upgrade_schema ($db, $db_type, $db_name, $display_results) {
function db_upgrade_schema ($db, $db_type, $db_name, $response_output) {
global $text; // pulls in language variable array
global $display_type;
global $response_format;
//PHP PDO check if table or column exists
//check if table exists
@@ -289,7 +289,7 @@ function db_upgrade_schema ($db, $db_type, $db_name, $display_results) {
//check if table exists
// SELECT * FROM pg_tables WHERE schemaname='public' AND table_name = 'v_groups'
//check if column exists
// SELECT attname FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'v_cdr') AND attname = 'caller_id_name';
// SELECT attname FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'v_cdr') AND attname = 'caller_id_name';
//mysql
//list all tables in the database
// SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = 'fusionpbx'
@@ -523,31 +523,35 @@ function db_upgrade_schema ($db, $db_type, $db_name, $display_results) {
}
}
}
// initialize response variable
$response = '';
//display results as html
if ($display_results && $display_type == "html") {
if ($response_output != '' && $response_format == "html") {
//show the database type
echo "<strong>".$text['header-database_type'].": ".$db_type. "</strong><br /><br />";
$response .= "<strong>".$text['header-database_type'].": ".$db_type. "</strong><br /><br />";
//start the table
echo "<table width='100%' border='0' cellpadding='20' cellspacing='0'>\n";
$response .= "<table width='100%' border='0' cellpadding='20' cellspacing='0'>\n";
//show the changes
if (strlen($sql_update) > 0) {
echo "<tr>\n";
echo "<td class='row_style1' colspan='3'>\n";
echo "<br />\n";
echo "<strong>".$text['label-sql_changes'].":</strong><br />\n";
echo "<pre>\n";
echo $sql_update;
echo "</pre>\n";
echo "<br />\n";
echo "</td>\n";
echo "</tr>\n";
$response .= "<tr>\n";
$response .= "<td class='row_style1' colspan='3'>\n";
$response .= "<br />\n";
$response .= "<strong>".$text['label-sql_changes'].":</strong><br />\n";
$response .= "<pre>\n";
$response .= $sql_update;
$response .= "</pre>\n";
$response .= "<br />\n";
$response .= "</td>\n";
$response .= "</tr>\n";
}
//list all tables
echo "<tr>\n";
echo "<th>".$text['label-table']."</th>\n";
echo "<th>".$text['label-exists']."</th>\n";
echo "<th>".$text['label-details']."</th>\n";
echo "<tr>\n";
$response .= "<tr>\n";
$response .= "<th>".$text['label-table']."</th>\n";
$response .= "<th>".$text['label-exists']."</th>\n";
$response .= "<th>".$text['label-details']."</th>\n";
$response .= "<tr>\n";
//build the html while looping through the app db array
$sql = '';
foreach ($apps as &$app) {
@@ -558,22 +562,22 @@ function db_upgrade_schema ($db, $db_type, $db_name, $display_results) {
else {
$table_name = $row['table'];
}
echo "<tr>\n";
$response .= "<tr>\n";
//check if the table exists
if ($row['exists'] == "true") {
echo "<td valign='top' class='row_style1'>".$table_name."</td>\n";
echo "<td valign='top' class='vncell' style='padding-top: 3px;'>".$text['option-true']."</td>\n";
$response .= "<td valign='top' class='row_style1'>".$table_name."</td>\n";
$response .= "<td valign='top' class='vncell' style='padding-top: 3px;'>".$text['option-true']."</td>\n";
if (count($row['fields']) > 0) {
echo "<td class='row_style1'>\n";
$response .= "<td class='row_style1'>\n";
//show the list of columns
echo "<table border='0' cellpadding='10' cellspacing='0'>\n";
echo "<tr>\n";
echo "<th>".$text['label-name']."</th>\n";
echo "<th>".$text['label-type']."</th>\n";
echo "<th>".$text['label-exists']."</th>\n";
echo "</tr>\n";
$response .= "<table border='0' cellpadding='10' cellspacing='0'>\n";
$response .= "<tr>\n";
$response .= "<th>".$text['label-name']."</th>\n";
$response .= "<th>".$text['label-type']."</th>\n";
$response .= "<th>".$text['label-exists']."</th>\n";
$response .= "</tr>\n";
foreach ($row['fields'] as $field) {
if ($field['deprecated'] == "true") {
//skip this field
@@ -591,47 +595,48 @@ function db_upgrade_schema ($db, $db_type, $db_name, $display_results) {
else {
$field_type = $field['type'];
}
echo "<tr>\n";
echo "<td class='row_style1' width='200'>".$field_name."</td>\n";
echo "<td class='row_style1'>".$field_type."</td>\n";
$response .= "<tr>\n";
$response .= "<td class='row_style1' width='200'>".$field_name."</td>\n";
$response .= "<td class='row_style1'>".$field_type."</td>\n";
if ($field['exists'] == "true") {
echo "<td class='row_style0' style=''>".$text['option-true']."</td>\n";
echo "<td>&nbsp;</td>\n";
$response .= "<td class='row_style0' style=''>".$text['option-true']."</td>\n";
$response .= "<td>&nbsp;</td>\n";
}
else {
echo "<td class='row_style1' style='background-color:#444444;color:#CCCCCC;'>".$text['option-false']."</td>\n";
echo "<td>&nbsp;</td>\n";
$response .= "<td class='row_style1' style='background-color:#444444;color:#CCCCCC;'>".$text['option-false']."</td>\n";
$response .= "<td>&nbsp;</td>\n";
}
echo "</tr>\n";
$response .= "</tr>\n";
}
}
unset($column_array);
echo " </table>\n";
echo "</td>\n";
$response .= " </table>\n";
$response .= "</td>\n";
}
}
else {
echo "<td valign='top' class='row_style1'>$table_name</td>\n";
echo "<td valign='top' class='row_style1' style='background-color:#444444;color:#CCCCCC;'><strong>".$text['label-exists']."</strong><br />".$text['option-false']."</td>\n";
echo "<td valign='top' class='row_style1'>&nbsp;</td>\n";
$response .= "<td valign='top' class='row_style1'>$table_name</td>\n";
$response .= "<td valign='top' class='row_style1' style='background-color:#444444;color:#CCCCCC;'><strong>".$text['label-exists']."</strong><br />".$text['option-false']."</td>\n";
$response .= "<td valign='top' class='row_style1'>&nbsp;</td>\n";
}
echo "</tr>\n";
$response .= "</tr>\n";
}
}
unset ($prep_statement);
//end the list of tables
echo "</table>\n";
echo "<br />\n";
$response .= "</table>\n";
$response .= "<br />\n";
}
//loop line by line through all the lines of sql code
$x = 0;
if (strlen($sql_update) == 0 && $display_type == "text") {
echo " ".$text['label-schema'].": ".$text['label-no_change']."\n";
if (strlen($sql_update) == 0 && $response_format == "text") {
$response .= " ".$text['label-schema'].": ".$text['label-no_change']."\n";
}
else {
if ($display_type == "text") {
echo " ".$text['label-schema'].":\n";
if ($response_format == "text") {
$response .= " ".$text['label-schema'].":\n";
}
//$db->beginTransaction();
$update_array = explode(";", $sql_update);
@@ -639,22 +644,31 @@ function db_upgrade_schema ($db, $db_type, $db_name, $display_results) {
if (strlen(trim($sql))) {
try {
$db->query(trim($sql));
if ($display_type == "text") {
echo " $sql\n";
if ($response_format == "text") {
$response .= " $sql\n";
}
}
catch (PDOException $error) {
if ($display_results) {
echo " error: " . $error->getMessage() . " sql: $sql<br/>";
if ($response_output != '') {
$response .= " error: " . $error->getMessage() . " sql: $sql<br/>";
}
}
}
}
//$db->commit();
echo "\n";
$response .= "\n";
unset ($file_contents, $sql_update, $sql);
}
//handle response
if ($response_output == "echo") {
echo $response;
}
else if ($response_output == "return") {
return $response;
}
} //end function
?>