implementation of PMA_handleTheViews()

This commit is contained in:
Thilina Buddika 2012-07-26 00:06:30 +05:30
parent d3a599bc4e
commit b2b394f583
2 changed files with 36 additions and 20 deletions

View File

@ -115,27 +115,9 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
// handle the views
if (! $_error) {
// temporarily force to add DROP IF EXIST to CREATE VIEW query,
// to remove stand-in VIEW that was created earlier
if (isset($GLOBALS['drop_if_exists'])) {
$temp_drop_if_exists = $GLOBALS['drop_if_exists'];
}
$GLOBALS['drop_if_exists'] = 'true';
foreach ($views as $view) {
if (! PMA_Table::moveCopy($db, $view, $newname, $view, 'structure', $move, 'db_copy')) {
$_error = true;
break;
}
}
unset($GLOBALS['drop_if_exists']);
if (isset($temp_drop_if_exists)) {
// restore previous value
$GLOBALS['drop_if_exists'] = $temp_drop_if_exists;
unset($temp_drop_if_exists);
}
$_error = PMA_handleTheViews($views, $move);
}
unset($view, $views);
unset($views);
// now that all tables exist, create all the accumulated constraints
if (! $_error && count($GLOBALS['sql_constraints_query_full_db']) > 0) {

View File

@ -492,4 +492,38 @@ function PMA_runEventDefinitionsForDb()
}
}
/**
* Handle the views, return the boolean value whether table rename/copy or not
*
* @param array $views views as an array
* @param boolean $move whether databse name is empty or not
*
* @return boolean $_error whether table rename/copy or not
*/
function PMA_handleTheViews($views, $move)
{
$_error = false;
// temporarily force to add DROP IF EXIST to CREATE VIEW query,
// to remove stand-in VIEW that was created earlier
if (isset($GLOBALS['drop_if_exists'])) {
$temp_drop_if_exists = $GLOBALS['drop_if_exists'];
}
$GLOBALS['drop_if_exists'] = 'true';
foreach ($views as $view) {
if (! PMA_Table::moveCopy($GLOBALS['db'], $view, $_REQUEST['newname'],
$view, 'structure', $move, 'db_copy')
) {
$_error = true;
break;
}
}
unset($GLOBALS['drop_if_exists']);
if (isset($temp_drop_if_exists)) {
// restore previous value
$GLOBALS['drop_if_exists'] = $temp_drop_if_exists;
}
return $_error;
}
?>