Browse Source

Merge branch 'master' into uploader

Tobias Reich 10 years ago
parent
commit
e332b0b167
1 changed files with 10 additions and 4 deletions
  1. 10 4
      php/modules/Database.php

+ 10 - 4
php/modules/Database.php

@@ -73,10 +73,16 @@ class Database extends Module {
 
 		if ($database->connect_errno) return 'Warning: Connection failed!';
 
-		# Check if user can create a database
-		$result = $database->query('CREATE DATABASE lychee_dbcheck');
-		if (!$result) return 'Warning: Creation failed!';
-		else $database->query('DROP DATABASE lychee_dbcheck');
+		# Check if database exists
+		if (!$database->select_db($name)) {
+
+			# Database doesn't exist
+			# Check if user can create a database
+			$result = $database->query('CREATE DATABASE lychee_dbcheck');
+			if (!$result) return 'Warning: Creation failed!';
+			else $database->query('DROP DATABASE lychee_dbcheck');
+
+		}
 
 		# Save config.php
 $config = "<?php