Skip to content

Commit

Permalink
FIX improved Adminer copying tables and views (now without data)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrej Kabachnik committed Apr 26, 2024
1 parent 8513d06 commit 2ed7702
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Adminer/adminer/drivers/mysql.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -829,10 +829,12 @@ function move_tables($tables, $views, $target) {
function copy_tables($tables, $views, $target) {
queries("SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'");
foreach ($tables as $table) {
$name = ($target == DB ? table("copy_$table") : idf_escape($target) . "." . table($table));
$name = ($target == DB ? table("{$table}_copy") : idf_escape($target) . "." . table($table));
if (($_POST["overwrite"] && !queries("\nDROP TABLE IF EXISTS $name"))
|| !queries("CREATE TABLE $name LIKE " . table($table))
|| !queries("INSERT INTO $name SELECT * FROM " . table($table))
// MOD ExFace do not copy data
// TODO add a checkbox in the UI for this
// || !queries("INSERT INTO $name SELECT * FROM " . table($table))
) {
return false;
}
Expand All @@ -844,7 +846,7 @@ function copy_tables($tables, $views, $target) {
}
}
foreach ($views as $table) {
$name = ($target == DB ? table("$table_copy") : idf_escape($target) . "." . table($table));
$name = ($target == DB ? table("{$table}_copy") : idf_escape($target) . "." . table($table));
$view = view($table);
if (($_POST["overwrite"] && !queries("DROP VIEW IF EXISTS $name"))
|| !queries("CREATE VIEW $name AS $view[select]")) { //! USE to avoid db.table
Expand Down

0 comments on commit 2ed7702

Please sign in to comment.