From 11c75eab4d04b9c88b0096015fb3c0711555bf9a Mon Sep 17 00:00:00 2001 From: Derek Allard Date: Tue, 29 Jan 2008 19:35:31 +0000 Subject: Removed support for db_backup in MySQLi due to incompatible functions. --- system/database/drivers/mysqli/mysqli_utility.php | 138 +--------------------- user_guide/changelog.html | 1 + user_guide/database/utilities.html | 2 +- 3 files changed, 5 insertions(+), 136 deletions(-) diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php index bb1f6f917..4ab2bb1d1 100644 --- a/system/database/drivers/mysqli/mysqli_utility.php +++ b/system/database/drivers/mysqli/mysqli_utility.php @@ -78,143 +78,11 @@ class CI_DB_mysqli_utility extends CI_DB_utility { */ function _backup($params = array()) { - if (count($params) == 0) - { - return FALSE; - } - - // Extract the prefs for simplicity - extract($params); - - // Build the output - $output = ''; - foreach ((array)$tables as $table) - { - // Is the table in the "ignore" list? - if (in_array($table, (array)$ignore, TRUE)) - { - continue; - } - - // Get the table schema - $query = $this->db->query("SHOW CREATE TABLE `".$this->db->database.'`.'.$table); - - // No result means the table name was invalid - if ($query === FALSE) - { - continue; - } - - // Write out the table schema - $output .= '#'.$newline.'# TABLE STRUCTURE FOR: '.$table.$newline.'#'.$newline.$newline; - - if ($add_drop == TRUE) - { - $output .= 'DROP TABLE IF EXISTS '.$table.';'.$newline.$newline; - } - - $i = 0; - $result = $query->result_array(); - foreach ($result[0] as $val) - { - if ($i++ % 2) - { - $output .= $val.';'.$newline.$newline; - } - } - - // If inserts are not needed we're done... - if ($add_insert == FALSE) - { - continue; - } - - // Grab all the data from the current table - $query = $this->db->query("SELECT * FROM $table"); - - if ($query->num_rows() == 0) - { - continue; - } - - // Fetch the field names and determine if the field is an - // integer type. We use this info to decide whether to - // surround the data with quotes or not - - $i = 0; - $field_str = ''; - $is_int = array(); - while ($field = mysqli_fetch_field($query->result_id)) - { - // Most versions of MySQL store timestamp as a string - $is_int[$i] = (in_array( - strtolower(mysql_field_type($query->result_id, $i)), - array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), // 'timestamp'), - TRUE) - ) ? TRUE : FALSE; - - // Create a string of field names - $field_str .= $field->name.', '; - $i++; - } - - // Trim off the end comma - $field_str = preg_replace( "/, $/" , "" , $field_str); - - - // Build the insert string - foreach ($query->result_array() as $row) - { - $val_str = ''; - - $i = 0; - foreach ($row as $v) - { - // Is the value NULL? - if ($v === NULL) - { - $val_str .= 'NULL'; - } - else - { - // Do a little formatting... - $v = str_replace(array("\x00", "\x0a", "\x0d", "\x1a"), array('\0', '\n', '\r', '\Z'), $v); - $v = str_replace(array("\n", "\r", "\t"), array('\n', '\r', '\t'), $v); - $v = str_replace('\\', '\\\\', $v); - $v = str_replace('\'', '\\\'', $v); - $v = str_replace('\\\n', '\n', $v); - $v = str_replace('\\\r', '\r', $v); - $v = str_replace('\\\t', '\t', $v); - - // Escape the data if it's not an integer - if ($is_int[$i] == FALSE) - { - $val_str .= $this->db->escape($v); - } - else - { - $val_str .= $v; - } - } - - // Append a comma - $val_str .= ', '; - $i++; - } - - // Remove the comma at the end of the string - $val_str = preg_replace( "/, $/" , "" , $val_str); - - // Build the INSERT string - $output .= 'INSERT INTO '.$table.' ('.$field_str.') VALUES ('.$val_str.');'.$newline; - } - - $output .= $newline.$newline; - } - - return $output; + // Currently unsupported + return $this->db->display_error('db_unsuported_feature'); } + /** * * The functions below have been deprecated as of 1.6, and are only here for backwards diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 645d5ae01..1ab6ac221 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -136,6 +136,7 @@ Change Log
  • Added quotes_to_entities() function to string helper.
  • Added form_fieldset(), form_fieldset_close(), form_label(), and form_reset() function to form helper.
  • Added support for external urls in form_open().
  • +
  • Removed support for db_backup in MySQLi due to incompatible functions.
  • Javascript Calendar plugin now uses the months and days from the calendar language file, instead of hard-coded values, internationalizing it.
  • diff --git a/user_guide/database/utilities.html b/user_guide/database/utilities.html index cf0230dbb..9b5126490 100644 --- a/user_guide/database/utilities.html +++ b/user_guide/database/utilities.html @@ -206,7 +206,7 @@ If you need to write the file use the File

    Permits you to backup your full database or individual tables. The backup data can be compressed in either Zip or Gzip format.

    -

    Note:  This features is only available for MySQL/MySQLi databases.

    +

    Note:  This features is only available for MySQL databases.

    Note: Due to the limited execution time and memory available to PHP, backing up very large databases may not be possible. If your database is very large you might need to backup directly from your SQL server -- cgit v1.2.3-24-g4f1b