Permalink
Browse files

Merge pull request #1212 from joaopaulofilho/master

correctly detects if there is a database and if there [are] any tables [created]
  • Loading branch information...
TheBrenny committed Jul 8, 2017
2 parents e32c5e5 + 74f80ae commit 6f6e696f8b8f67ea13cf354496e2d380dd0841fd
Showing with 16 additions and 13 deletions.
  1. +16 −13 install/libraries/installer.php
@@ -20,19 +20,22 @@ public static function run()
// check we have not already installed
if (!static::$connection->instance()->query('SHOW DATABASES LIKE ' . static::$connection->instance()->quote($settings['database']['name']) . ';')->fetchColumn()) {
// create the database and use the database
static::$connection->instance()->query('CREATE DATABASE ' . substr(static::$connection->instance()->quote($settings['database']['name']),1,-1) . ';');
static::$connection->instance()->query('USE ' . substr(static::$connection->instance()->quote($settings['database']['name']),1,-1) . ';');
// install tables
static::schema($settings);
// insert metadata
static::metadata($settings);
// create user account
static::account($settings);
// create the database
static::$connection->instance()->query('CREATE DATABASE ' . substr(static::$connection->instance()->quote($settings['database']['name']),1,-1) . ';');
}
// use the database
static::$connection->instance()->query('USE ' . substr(static::$connection->instance()->quote($settings['database']['name']),1,-1) . ';');
if (!static::$connection->instance()->query('SHOW TABLES;')->fetchColumn()) {
// install tables
static::schema($settings);
// insert metadata
static::metadata($settings);
// create user account
static::account($settings);
}
// write database config

0 comments on commit 6f6e696

Please sign in to comment.