From 1d57a13267c37486f0200e26331ed64d24c70c78 Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Fri, 8 Aug 2014 16:28:34 +0200 Subject: [PATCH] Fixed "Setup tries to create database lychee_dbcheck #202" --- php/modules/Database.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/php/modules/Database.php b/php/modules/Database.php index 32d6af9..cb32ef5 100755 --- a/php/modules/Database.php +++ b/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 = "