Index: includes/destinations.db.mysql.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/backup_migrate/includes/Attic/destinations.db.mysql.inc,v retrieving revision 1.1.2.4 diff -u -p -r1.1.2.4 destinations.db.mysql.inc --- includes/destinations.db.mysql.inc 26 Nov 2009 21:58:21 -0000 1.1.2.4 +++ includes/destinations.db.mysql.inc 17 Dec 2010 10:09:37 -0000 @@ -90,6 +90,7 @@ class backup_migrate_destination_db_mysq if ($file->open(TRUE)) { $file->write($this->_get_sql_file_header()); $alltables = $this->_get_tables(); + $allviews = $this->_get_views(); foreach ($alltables as $table) { if (_backup_migrate_check_timeout()) { return FALSE; @@ -102,6 +103,13 @@ class backup_migrate_destination_db_mysq } } } + foreach ($allviews as $view) { + if (_backup_migrate_check_timeout()) { + return FALSE; + } + $file->write($this->_get_view_create_sql($view)); + + } $file->write($this->_get_sql_file_footer()); $file->close(); return $lines; @@ -177,9 +185,26 @@ class backup_migrate_destination_db_mysq function _get_tables() { $out = array(); // get auto_increment values and names of all tables + $tables = db_query("show table status"); + while ($table = db_fetch_array($tables)) { + if (!empty($table['Engine'])) { + $out[$table['Name']] = $table; + } + } + return $out; + } + + /** + * Get a list of views in the db. + */ + function _get_views() { + $out = array(); + // get auto_increment values and names of all tables $tables = db_query("show table status"); while ($table = db_fetch_array($tables)) { - $out[$table['Name']] = $table; + if (empty($table['Engine'])) { + $out[$table['Name']] = $table; + } } return $out; } @@ -200,6 +225,20 @@ class backup_migrate_destination_db_mysq } return $out; } + + /** + * Get the sql for the structure of the given table. + */ + function _get_view_create_sql($view) { + $out = ""; + $result = db_query("SHOW CREATE VIEW `". $view['Name'] ."`"); + if ($create = db_fetch_array($result)) { + $out .= "DROP VIEW IF EXISTS `". $view['Name'] ."`;\n"; + $out .= strtr($create['Create View'], "\n", " " ); + $out .= ";\n"; + } + return $out; + } /** * Get the sql to insert the data for a given table