Skip to content

Commit

Permalink
oop: modify PMA_getTableDef and PMA_getTableDefStandIn usage
Browse files Browse the repository at this point in the history
  • Loading branch information
amarin15 committed Jun 9, 2012
1 parent 3e406e2 commit ff930b7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
14 changes: 11 additions & 3 deletions db_operations.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,19 @@
$views = array();

// remove all foreign key constraints, otherwise we can get errors
include_once 'libraries/export/sql.php';
$export_sql_plugin = PMA_getPlugin(
"export",
"sql",
'libraries/plugins/export/',
array(
'export_type' => $export_type,
'single_table' => isset($single_table)
)
);
foreach ($tables_full as $each_table => $tmp) {
$sql_constraints = '';
$sql_drop_foreign_keys = '';
$sql_structure = PMA_getTableDef($db, $each_table, "\n", '', false, false);
$sql_structure = $export_sql_plugin->getTableDef($db, $each_table, "\n", '', false, false);
if ($move && ! empty($sql_drop_foreign_keys)) {
PMA_DBI_query($sql_drop_foreign_keys);
}
Expand All @@ -154,7 +162,7 @@
if (PMA_Table::isView($db, $each_table)) {
$views[] = $each_table;
// Create stand-in definition to resolve view dependencies
$sql_view_standin = PMA_getTableDefStandIn($db, $each_table, "\n");
$sql_view_standin = $export_sql_plugin->getTableDefStandIn($db, $each_table, "\n");
PMA_DBI_select_db($newname);
PMA_DBI_query($sql_view_standin);
$GLOBALS['sql_query'] .= "\n" . $sql_view_standin;
Expand Down
23 changes: 16 additions & 7 deletions libraries/Table.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -794,12 +794,21 @@ static public function moveCopy($source_db, $source_table, $target_db,

// do not create the table if dataonly
if ($what != 'dataonly') {
include_once './libraries/export/sql.php';
// get Export SQL instance
$export_sql_plugin = PMA_getPlugin(
"export",
"sql",
'libraries/plugins/export/',
array(
'export_type' => $export_type,
'single_table' => isset($single_table)
)
);

$no_constraints_comments = true;
$GLOBALS['sql_constraints_query'] = '';

$sql_structure = PMA_getTableDef(
$sql_structure = $export_sql_plugin->getTableDef(
$source_db, $source_table, "\n", $err_url, false, false
);
unset($no_constraints_comments);
Expand Down Expand Up @@ -990,11 +999,11 @@ static public function moveCopy($source_db, $source_table, $target_db,
if ($GLOBALS['cfgRelation']['commwork']) {
// Get all comments and MIME-Types for current table
$comments_copy_query = 'SELECT
column_name, comment' . ($GLOBALS['cfgRelation']['mimework'] ? ', mimetype, transformation, transformation_options' : '') . '
FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['column_info']) . '
WHERE
db_name = \'' . PMA_sqlAddSlashes($source_db) . '\' AND
table_name = \'' . PMA_sqlAddSlashes($source_table) . '\'';
column_name, comment' . ($GLOBALS['cfgRelation']['mimework'] ? ', mimetype, transformation, transformation_options' : '') . '
FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['column_info']) . '
WHERE
db_name = \'' . PMA_sqlAddSlashes($source_db) . '\' AND
table_name = \'' . PMA_sqlAddSlashes($source_table) . '\'';
$comments_copy_rs = PMA_query_as_controluser($comments_copy_query);

// Write every comment as new copied entry. [MIME]
Expand Down
13 changes: 11 additions & 2 deletions libraries/Tracker.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,16 @@ static public function createVersion($dbname, $tablename, $version,
$tracking_set = self::$default_tracking_set;
}

include_once './libraries/export/sql.php';
// get Export SQL instance
$export_sql_plugin = PMA_getPlugin(
"export",
"sql",
'libraries/plugins/export/',
array(
'export_type' => $export_type,
'single_table' => isset($single_table)
)
);

$sql_backquotes = true;

Expand Down Expand Up @@ -295,7 +304,7 @@ static public function createVersion($dbname, $tablename, $version,
}

$create_sql .= self::getLogComment() .
PMA_getTableDef($dbname, $tablename, "\n", "");
$export_sql_plugin->getTableDef($dbname, $tablename, "\n", "");

// Save version

Expand Down

0 comments on commit ff930b7

Please sign in to comment.