Rename tables by single command
This commit is contained in:
parent
d77b0bbe0d
commit
515325ac22
|
@ -544,22 +544,18 @@ if (!defined("DRIVER")) {
|
||||||
*/
|
*/
|
||||||
function rename_database($name, $collation) {
|
function rename_database($name, $collation) {
|
||||||
global $connection;
|
global $connection;
|
||||||
$return = false;
|
|
||||||
if (create_database($name, $collation)) {
|
if (create_database($name, $collation)) {
|
||||||
//! move triggers
|
//! move triggers
|
||||||
$return = true; // table list may by empty
|
$rename = array();
|
||||||
foreach (tables_list() as $table) {
|
foreach (tables_list() as $table => $type) {
|
||||||
if (!queries("RENAME TABLE " . table($table) . " TO " . idf_escape($name) . "." . table($table))) {
|
$rename[] = table($table) . " TO " . idf_escape($name) . "." . table($table);
|
||||||
$return = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ($return) {
|
if (!$rename || queries("RENAME TABLE " . implode(", ", $rename))) {
|
||||||
queries("DROP DATABASE " . idf_escape(DB));
|
queries("DROP DATABASE " . idf_escape(DB));
|
||||||
//! saved to history of removed database
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Generate modifier for auto increment column
|
/** Generate modifier for auto increment column
|
||||||
|
|
Loading…
Reference in a new issue