Fixed creation of test db #295

This commit is contained in:
Tobias Reich 2015-01-23 20:50:21 +01:00
parent a42c9810a2
commit 7a3695e192

View File

@ -84,10 +84,9 @@ class Database extends Module {
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');
# Check if user can create the database
$result = Database::createDatabase($database, $name);
if ($result===false) return 'Warning: Creation failed!';
}
@ -131,8 +130,8 @@ if(!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
Module::dependencies(isset($database, $name));
# Create database
$result = $database->query("CREATE DATABASE IF NOT EXISTS $name;");
$database->select_db($name);
$query = Database::prepare($database, 'CREATE DATABASE IF NOT EXISTS ?', array($name));
$result = $database->query($query);
if (!$database->select_db($name)||!$result) return false;
return true;