mirror of
https://github.com/vrana/adminer.git
synced 2025-08-12 01:24:17 +02:00
Copy tables (bug #3158027)
This commit is contained in:
@@ -646,6 +646,7 @@ if (!defined("DRIVER")) {
|
||||
|
||||
/** Move tables to other schema
|
||||
* @param array
|
||||
* @param array
|
||||
* @param string
|
||||
* @return bool
|
||||
*/
|
||||
@@ -658,6 +659,34 @@ if (!defined("DRIVER")) {
|
||||
//! move triggers
|
||||
}
|
||||
|
||||
/** Copy tables to other schema
|
||||
* @param array
|
||||
* @param array
|
||||
* @param string
|
||||
* @return bool
|
||||
*/
|
||||
function copy_tables($tables, $views, $target) {
|
||||
foreach ($tables as $table) {
|
||||
$name = ($target == DB ? table("copy_$table") : idf_escape($target) . "." . table($table));
|
||||
if (!queries("DROP TABLE IF EXISTS $name")
|
||||
|| !queries("CREATE TABLE $name LIKE " . table($table))
|
||||
|| !queries("INSERT INTO $name SELECT * FROM " . table($table))
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
foreach ($views as $table) {
|
||||
$name = ($target == DB ? table("copy_$table") : idf_escape($target) . "." . table($table));
|
||||
$view = view($table);
|
||||
if (!queries("DROP VIEW IF EXISTS $name")
|
||||
|| !queries("CREATE VIEW $name AS $view[select]") //! USE to avoid db.table
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Get information about trigger
|
||||
* @param string trigger name
|
||||
* @return array array("Trigger" => , "Timing" => , "Event" => , "Statement" => )
|
||||
@@ -865,7 +894,7 @@ if (!defined("DRIVER")) {
|
||||
}
|
||||
|
||||
/** Check whether a feature is supported
|
||||
* @param string "comment", "drop_col", "dump", "event", "partitioning", "routine", "scheme", "sequence", "status", "trigger", "type", "variables", "view"
|
||||
* @param string "comment", "drop_col", "dump", "event", "partitioning", "routine", "scheme", "sequence", "status", "trigger", "type", "variables", "view", "copy"
|
||||
* @return bool
|
||||
*/
|
||||
function support($feature) {
|
||||
|
Reference in New Issue
Block a user