diff --git a/install/install.php b/install/install.php index b205aaa52..ba25cc8f5 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 38d372ff5..a99990757 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) {