From 4a86288c66647ade4256a92846630e304185253c Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 21 Feb 2017 07:30:14 +0100 Subject: [PATCH] add support for postgresql --- install/install.php | 7 +++++++ install/update.php | 12 +++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/install/install.php b/install/install.php index f8bb1ddb5..77efd3b42 100644 --- a/install/install.php +++ b/install/install.php @@ -37,6 +37,10 @@ if (!file_exists("create_tables-sqlite3.sql")) { echo "Can't install SeedDMS, 'create_tables-sqlite3.sql' missing"; exit; } +if (!file_exists("create_tables-postgres.sql")) { + echo "Can't install SeedDMS, 'create_tables-postgres.sql' missing"; + exit; +} if (!file_exists("settings.xml.template_install")) { echo "Can't install SeedDMS, 'settings.xml.template_install' missing"; exit; @@ -50,6 +54,7 @@ function openDBConnection($settings) { /* {{{ */ case 'mysql': case 'mysqli': case 'mysqlnd': + case 'pgsql': $tmp = explode(":", $settings->_dbHostname); $dsn = $settings->_dbDriver.":dbname=".$settings->_dbDatabase.";host=".$tmp[0]; if(isset($tmp[1])) @@ -297,6 +302,8 @@ if ($action=="setSettings") { $queries = file_get_contents("create_tables-innodb.sql"); elseif($settings->_dbDriver=="sqlite") $queries = file_get_contents("create_tables-sqlite3.sql"); + elseif($settings->_dbDriver=="pgsql") + $queries = file_get_contents("create_tables-postgres.sql"); else die(); diff --git a/install/update.php b/install/update.php index 23e1714ce..0682492d4 100644 --- a/install/update.php +++ b/install/update.php @@ -49,13 +49,23 @@ switch($settings->_dbDriver) { case 'mysql': case 'mysqli': case 'mysqlnd': - $dsn = $settings->_dbDriver.":dbname=".$settings->_dbDatabase.";host=".$settings->_dbHostname; + $tmp = explode(":", $settings->_dbHostname); + $dsn = $settings->_dbDriver.":dbname=".$settings->_dbDatabase.";host=".$tmp[0]; + if(isset($tmp[1])) + $dsn .= ";port=".$tmp[1]; break; case 'sqlite': $dsn = $settings->_dbDriver.":".$settings->_dbDatabase; if(file_exists('update-'.$_GET['version'].'/update-sqlite3.sql')) $sqlfile = "update-sqlite3.sql"; break; + case 'pgsql': + $tmp = explode(":", $settings->_dbHostname); + $dsn = $settings->_dbDriver.":dbname=".$settings->_dbDatabase.";host=".$tmp[0]; + if(isset($tmp[1])) + $dsn .= ";port=".$tmp[1]; + if(file_exists('update-'.$_GET['version'].'/update-postgres.sql')) + $sqlfile = "update-postgres.sql"; } $db = new PDO($dsn, $settings->_dbUser, $settings->_dbPass); if (!$db) {