diff --git a/classes/db_pdo.php b/classes/db_pdo.php index 33f1b12..bbdb2df 100644 --- a/classes/db_pdo.php +++ b/classes/db_pdo.php @@ -401,7 +401,7 @@ abstract class DB_PDO extends PDO { * @param bool $filtered_index * @return mixed */ - protected function driver_query($sql, $filtered_index=TRUE) + public function driver_query($sql, $filtered_index=TRUE) { // Return if the query doesn't apply to the driver if ($sql === FALSE) diff --git a/drivers/mysql/mysql_util.php b/drivers/mysql/mysql_util.php index 4b5b0b4..79b818e 100644 --- a/drivers/mysql/mysql_util.php +++ b/drivers/mysql/mysql_util.php @@ -124,30 +124,30 @@ class MySQL_Util extends DB_Util { */ public function backup_structure() { - $sql = ''; + $string = array(); // Get databases - $dbs = $this->conn->get_dbs(); + $dbs = $this->get_dbs(); foreach($dbs as &$d) { - // Get the list of tables - $tables = $this->conn->driver_query("SHOW TABLES FROM `{$database}`"); - - // Get the list of views - $views = $this->conn->driver_query("SHOW VIEWS FROM `{$database}`"); - - $tav = array_merge($tabes,$views); - - foreach($tav as &$table) + // Skip built-in dbs + if ($d == 'mysql') { - $string = $this->conn->driver_query("SHOW CREATE TABLE {$table}"); + continue; } + + // Get the list of tables + $tables = $this->driver_query("SHOW TABLES FROM `{$d}`"); + foreach($tables as &$table) + { + $array = $this->driver_query("SHOW CREATE TABLE `{$d}`.`{$table}`", FALSE); + $string[] = $array[0]['Create Table']; + } } - // TODO Implement Backup function - return ''; + return implode("\n\n", $string); } // -------------------------------------------------------------------------- diff --git a/tests/databases/mysql/mysql.php b/tests/databases/mysql/mysql.php index c9556b7..d119d3e 100644 --- a/tests/databases/mysql/mysql.php +++ b/tests/databases/mysql/mysql.php @@ -192,4 +192,9 @@ SQL; { $this->assertFalse($this->db->get_sequences()); } + + public function TestBackup() + { + $this->assertTrue(is_string($this->db->util->backup_structure())); + } } \ No newline at end of file diff --git a/tests/db_files/FB_TEST_DB.FDB b/tests/db_files/FB_TEST_DB.FDB index 80be6d4..fc4aad5 100644 Binary files a/tests/db_files/FB_TEST_DB.FDB and b/tests/db_files/FB_TEST_DB.FDB differ