Add IF NOT EXISTS to CREATE DATABASE query (RFE #1608372), reload navigation after creating database.

This commit is contained in:
Michal Čihař
2006-12-05 10:11:16 +00:00
parent 8ff15cb214
commit a247be5fc0
2 changed files with 7 additions and 1 deletions

View File

@@ -836,9 +836,11 @@ if (!empty($adduser_submit) || !empty($change_copy)) {
/* Create database for new user */
if (isset($createdb) && $createdb > 0) {
if ($createdb == 1) {
$q = 'CREATE DATABASE ' . PMA_backquote(PMA_sqlAddslashes($username)) . ';';
$q = 'CREATE DATABASE IF NOT EXISTS ' . PMA_backquote(PMA_sqlAddslashes($username)) . ';';
$sql_query .= $q;
PMA_DBI_try_query($q) or PMA_mysqlDie(PMA_DBI_getError(), $sql_query);
$GLOBALS['reload'] = TRUE;
PMA_reloadNavigation();
$q = 'GRANT ALL PRIVILEGES ON ' . PMA_backquote(PMA_sqlAddslashes($username)) . '.* TO \'' . PMA_sqlAddslashes($username) . '\'@\'' . $hostname . '\';';
$sql_query .= $q;