Do not install if tables already exist

This commit is contained in:
Kijin Sung 2016-02-07 10:21:40 +09:00
parent 78cb8aea17
commit 5a7906252e
3 changed files with 13 additions and 1 deletions

View file

@ -40,7 +40,7 @@ class installController extends install
'user' => $config->db_user,
'pass' => $config->db_pass,
'database' => $config->db_database,
'prefix' => $config->db_prefix,
'prefix' => rtrim($config->db_prefix, '_') . '_',
));
// Check connection to the DB.
@ -78,6 +78,16 @@ class installController extends install
$config->db_charset = $oDB->charset;
}
// Check if tables already exist.
$table_check = array('documents', 'comments', 'modules', 'sites');
foreach ($table_check as $table_name)
{
if ($oDB->isTableExists($table_name))
{
return new Object(-1, 'msg_table_already_exists');
}
}
// Save DB config in session.
$_SESSION['db_config'] = $config;