diff options
author | admin <devnull@localhost> | 2006-09-30 21:24:45 +0200 |
---|---|---|
committer | admin <devnull@localhost> | 2006-09-30 21:24:45 +0200 |
commit | 3dd978f680076be842bfcb5c9e2cbf35b926373b (patch) | |
tree | e4cd05724744ee70eb497118692581e750539548 /system/database/drivers/mysql | |
parent | 3ed8c51254a5b26d951fa675802fcf69adf9638e (diff) |
Diffstat (limited to 'system/database/drivers/mysql')
-rw-r--r-- | system/database/drivers/mysql/mysql_driver.php | 28 | ||||
-rw-r--r-- | system/database/drivers/mysql/mysql_utility.php | 95 |
2 files changed, 42 insertions, 81 deletions
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 792e023a8..ecab648d4 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -292,6 +292,34 @@ class CI_DB_mysql_driver extends CI_DB { $row = $query->row(); return $row->numrows; } + + // -------------------------------------------------------------------- + + /** + * List databases + * + * @access private + * @return bool + */ + function _list_databases() + { + return "SHOW DATABASES"; + } + + // -------------------------------------------------------------------- + + /** + * List table query + * + * Generates a platform-specific query string so that the table names can be fetched + * + * @access private + * @return string + */ + function _list_tables() + { + return "SHOW TABLES FROM `".$this->database."`"; + } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php index f43299382..a81c915f6 100644 --- a/system/database/drivers/mysql/mysql_utility.php +++ b/system/database/drivers/mysql/mysql_utility.php @@ -53,34 +53,6 @@ class CI_DB_mysql_utility extends CI_DB_utility { // -------------------------------------------------------------------- /** - * List databases - * - * @access private - * @return bool - */ - function _list_databases() - { - return "SHOW DATABASES"; - } - - // -------------------------------------------------------------------- - - /** - * Show table query - * - * Generates a platform-specific query string so that the table names can be fetched - * - * @access private - * @return string - */ - function _list_tables() - { - return "SHOW TABLES FROM `".$this->db->database."`"; - } - - // -------------------------------------------------------------------- - - /** * Drop Table * * @access private @@ -132,50 +104,22 @@ class CI_DB_mysql_utility extends CI_DB_utility { * @param array Any preferences * @return mixed */ - function _export($params = array()) + function _backup($params = array()) { - // Set up our default preferences - $prefs = array( - 'tables' => array(), - 'ignore' => array(), - 'format' => 'gzip', - 'action' => 'download', // download, archive, echo, return - 'filename' => date('Y-m-d-H:i', time()), - 'filepath' => '', - 'add_drop' => TRUE, - 'add_insert' => TRUE, - 'newline' => "\n" - ); - - // Did the user submit any preference overrides? If so set them.... - if (count($params) > 0) + if (count($params) == 0) { - foreach ($prefs as $key => $val) - { - if (isset($params[$key])) - { - $prefs[$key] = $params[$key]; - } - } + return FALSE; } // Extract the prefs for simplicity - extract($prefs); - - // Are we backing up a complete database or individual tables? - if (count($tables) == 0) - { - $tables = $this->list_tables(); - } - - // Start buffering the output - ob_start(); + extract($params); // Build the output - foreach ($tables as $table) + $output = ''; + foreach ((array)$tables as $table) { // Is the table in the "ignore" list? - if (in_array($table, $ignore)) + if (in_array($table, (array)$ignore, TRUE)) { continue; } @@ -190,11 +134,11 @@ class CI_DB_mysql_utility extends CI_DB_utility { } // Write out the table schema - echo $newline.$newline.'#'.$newline.'# TABLE STRUCTURE FOR: '.$table.$newline.'#'.$newline.$newline; + $output .= '#'.$newline.'# TABLE STRUCTURE FOR: '.$table.$newline.'#'.$newline.$newline; if ($add_drop == TRUE) { - echo 'DROP TABLE IF EXISTS '.$table.';'.$newline.$newline; + $output .= 'DROP TABLE IF EXISTS '.$table.';'.$newline.$newline; } $i = 0; @@ -203,7 +147,7 @@ class CI_DB_mysql_utility extends CI_DB_utility { { if ($i++ % 2) { - echo $val.';'.$newline.$newline; + $output .= $val.';'.$newline.$newline; } } @@ -270,27 +214,16 @@ class CI_DB_mysql_utility extends CI_DB_utility { } $val_str = preg_replace( "/, $/" , "" , $val_str); - - if ($action == 'echo') - { - $val_str = htmlspecialchars($val_str); - } - + // Build the INSERT string - echo 'INSERT INTO '.$table.' ('.$field_str.') VALUES ('.$val_str.');'.$newline; + $output .= 'INSERT INTO '.$table.' ('.$field_str.') VALUES ('.$val_str.');'.$newline; } - - - $buffer = ob_get_contents(); - @ob_end_clean(); - - echo $buffer; - + $output .= $newline.$newline; } - + return $output; } |