/** * Get views as an array and create SQL view stand-in * * @param array $tables_full array of all tables in given db or dbs * @param ExportSql $export_sql_plugin export plugin instance * @param string $db database name * * @return array $views */ function PMA_getViewsAndCreateSqlViewStandIn($tables_full, $export_sql_plugin, $db) { $views = array(); foreach ($tables_full as $each_table => $tmp) { // to be able to rename a db containing views, // first all the views are collected and a stand-in is created // the real views are created after the tables if ($GLOBALS['dbi']->getTable($db, $each_table)->isView()) { // If view exists, and 'add drop view' is selected: Drop it! if ($_REQUEST['what'] != 'nocopy' && isset($_REQUEST['drop_if_exists']) && $_REQUEST['drop_if_exists'] == 'true') { $drop_query = 'DROP VIEW IF EXISTS ' . PMA_Util::backquote($_REQUEST['newname']) . '.' . PMA_Util::backquote($each_table); $GLOBALS['dbi']->query($drop_query); $GLOBALS['sql_query'] .= "\n" . $drop_query . ';'; } $views[] = $each_table; // Create stand-in definition to resolve view dependencies $sql_view_standin = $export_sql_plugin->getTableDefStandIn($db, $each_table, "\n"); $GLOBALS['dbi']->selectDb($_REQUEST['newname']); $GLOBALS['dbi']->query($sql_view_standin); $GLOBALS['sql_query'] .= "\n" . $sql_view_standin; } } return $views; }
/** * Get views as an array and create SQL view stand-in * * @param array $tables_full array of all tables in given db or dbs * @param ExportSql $export_sql_plugin export plugin instance * @param string $db database name * * @return array $views */ function PMA_getViewsAndCreateSqlViewStandIn($tables_full, $export_sql_plugin, $db) { $views = array(); foreach ($tables_full as $each_table => $tmp) { // to be able to rename a db containing views, // first all the views are collected and a stand-in is created // the real views are created after the tables if (PMA_Table::isView($db, $each_table)) { $views[] = $each_table; // Create stand-in definition to resolve view dependencies $sql_view_standin = $export_sql_plugin->getTableDefStandIn($db, $each_table, "\n"); $GLOBALS['dbi']->selectDb($_REQUEST['newname']); $GLOBALS['dbi']->query($sql_view_standin); $GLOBALS['sql_query'] .= "\n" . $sql_view_standin; } } return $views; }