From fac80cf79d0da6eb64c52a57a92da59d07f544bc Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 5 Jan 2016 13:18:52 +0100 Subject: [PATCH] made setup script compatible with postgres --- db/qq/QI.php | 24 ++++++++++++------- .../data/basic_locale_string.sql | 0 sql/qt/{pg => pgsql}/data/sai_api.sql | 0 .../data/sai_error_locale_string.sql | 0 .../{pg => pgsql}/data/sai_locale_string.sql | 0 sql/qt/{pg => pgsql}/data/system_api.sql | 0 sql/qt/{pg => pgsql}/data/system_cron.sql | 0 sql/qt/{pg => pgsql}/data/system_rights.sql | 0 .../schema => pgsql}/extension_pgcrypto.sql | 0 sql/qt/{pg => pgsql}/schema/schema.sql | 0 sql/qt/{pg => pgsql}/schema/system_api.sql | 0 sql/qt/{pg => pgsql}/schema/system_cache.sql | 0 sql/qt/{pg => pgsql}/schema/system_cron.sql | 0 .../schema/system_locale_string.sql | 0 sql/qt/{pg => pgsql}/schema/system_log.sql | 0 sql/qt/{pg => pgsql}/schema/system_rights.sql | 0 sql/qt/{pg => pgsql}/schema/system_text.sql | 0 .../{pg => pgsql}/schema/system_text_tag.sql | 0 sql/qt/{pg => pgsql}/schema/system_todo.sql | 0 sql/qt/{pg => pgsql}/schema/system_user.sql | 0 .../schema/system_user_to_rights.sql | 0 .../util_copy_api_table_by_group.sql} | 0 22 files changed, 15 insertions(+), 9 deletions(-) rename sql/qt/{pg => pgsql}/data/basic_locale_string.sql (100%) rename sql/qt/{pg => pgsql}/data/sai_api.sql (100%) rename sql/qt/{pg => pgsql}/data/sai_error_locale_string.sql (100%) rename sql/qt/{pg => pgsql}/data/sai_locale_string.sql (100%) rename sql/qt/{pg => pgsql}/data/system_api.sql (100%) rename sql/qt/{pg => pgsql}/data/system_cron.sql (100%) rename sql/qt/{pg => pgsql}/data/system_rights.sql (100%) rename sql/qt/{pg/schema => pgsql}/extension_pgcrypto.sql (100%) rename sql/qt/{pg => pgsql}/schema/schema.sql (100%) rename sql/qt/{pg => pgsql}/schema/system_api.sql (100%) rename sql/qt/{pg => pgsql}/schema/system_cache.sql (100%) rename sql/qt/{pg => pgsql}/schema/system_cron.sql (100%) rename sql/qt/{pg => pgsql}/schema/system_locale_string.sql (100%) rename sql/qt/{pg => pgsql}/schema/system_log.sql (100%) rename sql/qt/{pg => pgsql}/schema/system_rights.sql (100%) rename sql/qt/{pg => pgsql}/schema/system_text.sql (100%) rename sql/qt/{pg => pgsql}/schema/system_text_tag.sql (100%) rename sql/qt/{pg => pgsql}/schema/system_todo.sql (100%) rename sql/qt/{pg => pgsql}/schema/system_user.sql (100%) rename sql/qt/{pg => pgsql}/schema/system_user_to_rights.sql (100%) rename sql/qt/{pg/util_copy_api_table_by_groupa.sql => pgsql/util_copy_api_table_by_group.sql} (100%) diff --git a/db/qq/QI.php b/db/qq/QI.php index e560d90..89abaf2 100644 --- a/db/qq/QI.php +++ b/db/qq/QI.php @@ -6,9 +6,21 @@ class QI { $dbinfo = \SYSTEM\system::getSystemDBInfo();} if($dbinfo instanceof \SYSTEM\DB\DBInfoPG){ - $files = static::files_pg(); + $files = static::files_pgsql(); + $command = 'psql'. + ' -U ' . $dbinfo->m_user. + ' -d ' . $dbinfo->m_database. + ' -a '. + ' -f ${file} 2>&1'; } else if ($dbinfo instanceof \SYSTEM\DB\DBInfoMYS){ $files = static::files_mysql(); + $command = 'mysql'. + ' --host=' . $dbinfo->m_host. + ' --user=' . $dbinfo->m_user. + ' --password=' . $dbinfo->m_password. + ' --database=' . $dbinfo->m_database. + ' --default-character-set=utf8'. + ' --execute="SOURCE ${file}" 2>&1'; } else if ($dbinfo instanceof \SYSTEM\DB\DBInfoAMQP){ $files = static::files_amqp(); } else if ($dbinfo instanceof \SYSTEM\DB\DBInfoSQLite){ @@ -16,16 +28,10 @@ class QI { } else { throw new \Exception(static::get_class().' Could not understand Database Settings. Check ur Database Settings');} - $command = 'mysql'. - ' --host=' . $dbinfo->m_host. - ' --user=' . $dbinfo->m_user. - ' --password=' . $dbinfo->m_password. - ' --database=' . $dbinfo->m_database. - ' --default-character-set=utf8'. - ' --execute="SOURCE '; + $result = array(); foreach($files as $file){ - $output = shell_exec($command .$file. '" 2>&1'); + $output = shell_exec(str_replace('${file}', $file, $command)); $result[] = array($file,$output);} return $result; } diff --git a/sql/qt/pg/data/basic_locale_string.sql b/sql/qt/pgsql/data/basic_locale_string.sql similarity index 100% rename from sql/qt/pg/data/basic_locale_string.sql rename to sql/qt/pgsql/data/basic_locale_string.sql diff --git a/sql/qt/pg/data/sai_api.sql b/sql/qt/pgsql/data/sai_api.sql similarity index 100% rename from sql/qt/pg/data/sai_api.sql rename to sql/qt/pgsql/data/sai_api.sql diff --git a/sql/qt/pg/data/sai_error_locale_string.sql b/sql/qt/pgsql/data/sai_error_locale_string.sql similarity index 100% rename from sql/qt/pg/data/sai_error_locale_string.sql rename to sql/qt/pgsql/data/sai_error_locale_string.sql diff --git a/sql/qt/pg/data/sai_locale_string.sql b/sql/qt/pgsql/data/sai_locale_string.sql similarity index 100% rename from sql/qt/pg/data/sai_locale_string.sql rename to sql/qt/pgsql/data/sai_locale_string.sql diff --git a/sql/qt/pg/data/system_api.sql b/sql/qt/pgsql/data/system_api.sql similarity index 100% rename from sql/qt/pg/data/system_api.sql rename to sql/qt/pgsql/data/system_api.sql diff --git a/sql/qt/pg/data/system_cron.sql b/sql/qt/pgsql/data/system_cron.sql similarity index 100% rename from sql/qt/pg/data/system_cron.sql rename to sql/qt/pgsql/data/system_cron.sql diff --git a/sql/qt/pg/data/system_rights.sql b/sql/qt/pgsql/data/system_rights.sql similarity index 100% rename from sql/qt/pg/data/system_rights.sql rename to sql/qt/pgsql/data/system_rights.sql diff --git a/sql/qt/pg/schema/extension_pgcrypto.sql b/sql/qt/pgsql/extension_pgcrypto.sql similarity index 100% rename from sql/qt/pg/schema/extension_pgcrypto.sql rename to sql/qt/pgsql/extension_pgcrypto.sql diff --git a/sql/qt/pg/schema/schema.sql b/sql/qt/pgsql/schema/schema.sql similarity index 100% rename from sql/qt/pg/schema/schema.sql rename to sql/qt/pgsql/schema/schema.sql diff --git a/sql/qt/pg/schema/system_api.sql b/sql/qt/pgsql/schema/system_api.sql similarity index 100% rename from sql/qt/pg/schema/system_api.sql rename to sql/qt/pgsql/schema/system_api.sql diff --git a/sql/qt/pg/schema/system_cache.sql b/sql/qt/pgsql/schema/system_cache.sql similarity index 100% rename from sql/qt/pg/schema/system_cache.sql rename to sql/qt/pgsql/schema/system_cache.sql diff --git a/sql/qt/pg/schema/system_cron.sql b/sql/qt/pgsql/schema/system_cron.sql similarity index 100% rename from sql/qt/pg/schema/system_cron.sql rename to sql/qt/pgsql/schema/system_cron.sql diff --git a/sql/qt/pg/schema/system_locale_string.sql b/sql/qt/pgsql/schema/system_locale_string.sql similarity index 100% rename from sql/qt/pg/schema/system_locale_string.sql rename to sql/qt/pgsql/schema/system_locale_string.sql diff --git a/sql/qt/pg/schema/system_log.sql b/sql/qt/pgsql/schema/system_log.sql similarity index 100% rename from sql/qt/pg/schema/system_log.sql rename to sql/qt/pgsql/schema/system_log.sql diff --git a/sql/qt/pg/schema/system_rights.sql b/sql/qt/pgsql/schema/system_rights.sql similarity index 100% rename from sql/qt/pg/schema/system_rights.sql rename to sql/qt/pgsql/schema/system_rights.sql diff --git a/sql/qt/pg/schema/system_text.sql b/sql/qt/pgsql/schema/system_text.sql similarity index 100% rename from sql/qt/pg/schema/system_text.sql rename to sql/qt/pgsql/schema/system_text.sql diff --git a/sql/qt/pg/schema/system_text_tag.sql b/sql/qt/pgsql/schema/system_text_tag.sql similarity index 100% rename from sql/qt/pg/schema/system_text_tag.sql rename to sql/qt/pgsql/schema/system_text_tag.sql diff --git a/sql/qt/pg/schema/system_todo.sql b/sql/qt/pgsql/schema/system_todo.sql similarity index 100% rename from sql/qt/pg/schema/system_todo.sql rename to sql/qt/pgsql/schema/system_todo.sql diff --git a/sql/qt/pg/schema/system_user.sql b/sql/qt/pgsql/schema/system_user.sql similarity index 100% rename from sql/qt/pg/schema/system_user.sql rename to sql/qt/pgsql/schema/system_user.sql diff --git a/sql/qt/pg/schema/system_user_to_rights.sql b/sql/qt/pgsql/schema/system_user_to_rights.sql similarity index 100% rename from sql/qt/pg/schema/system_user_to_rights.sql rename to sql/qt/pgsql/schema/system_user_to_rights.sql diff --git a/sql/qt/pg/util_copy_api_table_by_groupa.sql b/sql/qt/pgsql/util_copy_api_table_by_group.sql similarity index 100% rename from sql/qt/pg/util_copy_api_table_by_groupa.sql rename to sql/qt/pgsql/util_copy_api_table_by_group.sql