fix drop database on mysql-5.6 as there is no 'if exists' for 'drop user' prior to mysql-5.7
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -146,7 +146,11 @@ class DbManagerMySQL
|
|||||||
));
|
));
|
||||||
|
|
||||||
// as of MySQL 5.0.2 this also revokes privileges. (requires MySQL 4.1.2+)
|
// as of MySQL 5.0.2 this also revokes privileges. (requires MySQL 4.1.2+)
|
||||||
|
if (version_compare(Database::getAttribute(\PDO::ATTR_SERVER_VERSION), '5.7.0', '<')) {
|
||||||
$drop_stmt = Database::prepare("DROP USER IF EXISTS :dbname@:host");
|
$drop_stmt = Database::prepare("DROP USER IF EXISTS :dbname@:host");
|
||||||
|
} else {
|
||||||
|
$drop_stmt = Database::prepare("DROP USER :dbname@:host");
|
||||||
|
}
|
||||||
while ($host = $host_res_stmt->fetch(\PDO::FETCH_ASSOC)) {
|
while ($host = $host_res_stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
Database::pexecute($drop_stmt, array(
|
Database::pexecute($drop_stmt, array(
|
||||||
'dbname' => $dbname,
|
'dbname' => $dbname,
|
||||||
@@ -154,6 +158,7 @@ class DbManagerMySQL
|
|||||||
), false);
|
), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$drop_stmt = Database::prepare("DROP DATABASE IF EXISTS `" . $dbname . "`");
|
$drop_stmt = Database::prepare("DROP DATABASE IF EXISTS `" . $dbname . "`");
|
||||||
Database::pexecute($drop_stmt);
|
Database::pexecute($drop_stmt);
|
||||||
}
|
}
|
||||||
@@ -172,7 +177,11 @@ class DbManagerMySQL
|
|||||||
Database::pexecute($stmt);
|
Database::pexecute($stmt);
|
||||||
}
|
}
|
||||||
// as of MySQL 5.0.2 this also revokes privileges. (requires MySQL 4.1.2+)
|
// as of MySQL 5.0.2 this also revokes privileges. (requires MySQL 4.1.2+)
|
||||||
|
if (version_compare(Database::getAttribute(\PDO::ATTR_SERVER_VERSION), '5.7.0', '<')) {
|
||||||
|
$stmt = Database::prepare("DROP USER IF EXISTS :username@:host");
|
||||||
|
} else {
|
||||||
$stmt = Database::prepare("DROP USER :username@:host");
|
$stmt = Database::prepare("DROP USER :username@:host");
|
||||||
|
}
|
||||||
Database::pexecute($stmt, array(
|
Database::pexecute($stmt, array(
|
||||||
"username" => $username,
|
"username" => $username,
|
||||||
"host" => $host
|
"host" => $host
|
||||||
|
|||||||
Reference in New Issue
Block a user