summaryrefslogtreecommitdiffstats
path: root/lib/setup.php
diff options
context:
space:
mode:
authorDaniel Köb <daniel.koeb@peony.at>2012-01-12 20:35:50 +0100
committerRobin Appelman <icewind1991@gmail.com>2012-01-13 04:38:59 +0100
commit37dbf48434525b008c5201136e38eee1aac16c9b (patch)
treeaedb294c025018e2e879b3b1cde897ab2c2cd813 /lib/setup.php
parent0ba472c18a0dee5404b9b8a458bf571ea6e8fec0 (diff)
downloadnextcloud-server-37dbf48434525b008c5201136e38eee1aac16c9b.tar.gz
nextcloud-server-37dbf48434525b008c5201136e38eee1aac16c9b.zip
Connect to the newly created database when checking if it needs to be filled.
Diffstat (limited to 'lib/setup.php')
-rw-r--r--lib/setup.php31
1 files changed, 22 insertions, 9 deletions
diff --git a/lib/setup.php b/lib/setup.php
index ce7ee24e134..eb32e84713f 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -189,16 +189,29 @@ class OC_Setup {
self::pg_createDatabase($dbname, $dbuser, $connection);
}
- //fill the database if needed
- $query = "select count(*) FROM pg_class WHERE relname='{$dbtableprefix}users' limit 1";
- $result = pg_query($connection, $query);
- if($result){
- $row = pg_fetch_row($result);
- }
- if(!$result or $row[0]==0) {
- OC_DB::createDbFromStructure('db_structure.xml');
- }
+ // the connection to dbname=postgres is not needed anymore
pg_close($connection);
+
+ // connect to the ownCloud database (dbname=$dbname) an check if it needs to be filled
+ $dbuser = OC_CONFIG::getValue('dbuser');
+ $dbpass = OC_CONFIG::getValue('dbpassword');
+ $connection_string = "host=$dbhost dbname=$dbname user=$dbuser password=$dbpass";
+ $connection = @pg_connect($connection_string);
+ if(!$connection) {
+ $error[] = array(
+ 'error' => 'PostgreSQL username and/or password not valid',
+ 'hint' => 'You need to enter either an existing account or the administrator.'
+ );
+ } else {
+ $query = "select count(*) FROM pg_class WHERE relname='{$dbtableprefix}users' limit 1";
+ $result = pg_query($connection, $query);
+ if($result) {
+ $row = pg_fetch_row($result);
+ }
+ if(!$result or $row[0]==0) {
+ OC_DB::createDbFromStructure('db_structure.xml');
+ }
+ }
}
}
else {