From 8fe6ec478c989b1bf83ed22368535a83d044a43d Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 29 Feb 2012 10:58:36 -0500 Subject: [PATCH] Added table filtering to backup_data method of firebird driver --- databases/firebird.php | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/databases/firebird.php b/databases/firebird.php index 3c15ed3..0912936 100644 --- a/databases/firebird.php +++ b/databases/firebird.php @@ -356,11 +356,28 @@ SQL; /** * Create an SQL backup file for the current database's data * + * @param array $exclude + * @param bool $system_tables * @return string */ - public function backup_data() + public function backup_data($exclude=array(), $system_tables=FALSE) { - $tables = $this->get_tables(); + // Determine which tables to use + if($system_tables == TRUE) + { + $tables = array_merge($this->get_system_tables(), $this->get_tables()); + } + else + { + $tables = $this->get_tables(); + } + + // Filter out the tables you don't want + if( ! empty($exclude)) + { + $tables = array_diff($tables, $exclude); + } + $output_sql = ''; @@ -374,7 +391,7 @@ SQL; unset($res); // Nab the column names by getting the keys of the first row - $columns = array_keys($obj_res[0]); + $columns = @array_keys($obj_res[0]); $insert_rows = array(); @@ -384,7 +401,11 @@ SQL; $row = array_values($row); // Quote values as needed by type - $row = array_map(array(&$this, 'quote'), $row); + if(stripos($t, 'RDB$') === FALSE) + { + $row = array_map(array(&$this, 'quote'), $row); + $row = array_map('trim', $row); + } $row_string = 'INSERT INTO "'.trim($t).'" ("'.implode('","', $columns).'") VALUES ('.implode(',', $row).');'; @@ -395,7 +416,7 @@ SQL; unset($obj_res); - $output_sql .= "\n\n".implode("\n", $insert_rows); + $output_sql .= "\n\nSET TRANSACTION;\n".implode("\n", $insert_rows)."\nCOMMIT;"; } return $output_sql;