blob: c4140aef302367e54ee7d9caa8f8a8854795d3f0 [file] [log] [blame]
Andrey Andreevc5536aa2012-11-01 17:33:58 +02001<?php
Derek Allard2067d1a2008-11-13 22:59:24 +00002/**
Derek Jonesf4a4bd82011-10-20 12:18:42 -05003 * CodeIgniter
Derek Allard2067d1a2008-11-13 22:59:24 +00004 *
Phil Sturgeon07c1ac82012-03-09 17:03:37 +00005 * An open source application development framework for PHP 5.2.4 or newer
Derek Allard2067d1a2008-11-13 22:59:24 +00006 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05007 * NOTICE OF LICENSE
Andrey Andreev24276a32012-01-08 02:44:38 +02008 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05009 * Licensed under the Open Software License version 3.0
Andrey Andreev24276a32012-01-08 02:44:38 +020010 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -050011 * This source file is subject to the Open Software License (OSL 3.0) that is
12 * bundled with this package in the files license.txt / license.rst. It is
13 * also available through the world wide web at this URL:
14 * http://opensource.org/licenses/OSL-3.0
15 * If you did not receive a copy of the license and are unable to obtain it
16 * through the world wide web, please send an email to
17 * licensing@ellislab.com so we can send you a copy immediately.
18 *
Derek Allard2067d1a2008-11-13 22:59:24 +000019 * @package CodeIgniter
Derek Jonesf4a4bd82011-10-20 12:18:42 -050020 * @author EllisLab Dev Team
Greg Aker0defe5d2012-01-01 18:46:41 -060021 * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
Derek Jonesf4a4bd82011-10-20 12:18:42 -050022 * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
Derek Allard2067d1a2008-11-13 22:59:24 +000023 * @link http://codeigniter.com
24 * @since Version 1.0
25 * @filesource
26 */
Andrey Andreevc5536aa2012-11-01 17:33:58 +020027defined('BASEPATH') OR exit('No direct script access allowed');
Derek Allard2067d1a2008-11-13 22:59:24 +000028
Derek Allard2067d1a2008-11-13 22:59:24 +000029/**
30 * Database Utility Class
31 *
32 * @category Database
Derek Jonesf4a4bd82011-10-20 12:18:42 -050033 * @author EllisLab Dev Team
Derek Allard2067d1a2008-11-13 22:59:24 +000034 * @link http://codeigniter.com/user_guide/database/
35 */
Andrey Andreeveaa60c72012-11-06 01:11:22 +020036abstract class CI_DB_utility {
Derek Allard2067d1a2008-11-13 22:59:24 +000037
Andrey Andreevae85eb42012-11-02 01:42:31 +020038 /**
39 * Database object
40 *
41 * @var object
42 */
Andrey Andreeveaa60c72012-11-06 01:11:22 +020043 protected $db;
Derek Allard2067d1a2008-11-13 22:59:24 +000044
Andrey Andreevae85eb42012-11-02 01:42:31 +020045 // --------------------------------------------------------------------
46
47 /**
Andrey Andreevc98e93a2012-11-02 02:04:59 +020048 * List databases statement
49 *
50 * @var string
51 */
Andrey Andreeva24e52e2012-11-02 03:54:12 +020052 protected $_list_databases = FALSE;
Andrey Andreevc98e93a2012-11-02 02:04:59 +020053
54 /**
Andrey Andreevae85eb42012-11-02 01:42:31 +020055 * OPTIMIZE TABLE statement
56 *
Andrey Andreevc98e93a2012-11-02 02:04:59 +020057 * @var string
Andrey Andreevae85eb42012-11-02 01:42:31 +020058 */
Andrey Andreevb457a402012-04-09 16:11:56 +030059 protected $_optimize_table = FALSE;
Andrey Andreevae85eb42012-11-02 01:42:31 +020060
61 /**
62 * REPAIR TABLE statement
63 *
Andrey Andreevc98e93a2012-11-02 02:04:59 +020064 * @var string
Andrey Andreevae85eb42012-11-02 01:42:31 +020065 */
Andrey Andreevb457a402012-04-09 16:11:56 +030066 protected $_repair_table = FALSE;
67
Andrey Andreevae85eb42012-11-02 01:42:31 +020068 // --------------------------------------------------------------------
69
Andrey Andreev5fd3ae82012-10-24 14:55:35 +030070 /**
Andrey Andreevc98e93a2012-11-02 02:04:59 +020071 * Class constructor
Andrey Andreev5fd3ae82012-10-24 14:55:35 +030072 *
Andrey Andreeveaa60c72012-11-06 01:11:22 +020073 * @param object &$db Database object
Andrey Andreev5fd3ae82012-10-24 14:55:35 +030074 * @return void
75 */
Andrey Andreeveaa60c72012-11-06 01:11:22 +020076 public function __construct(&$db)
Derek Allard2067d1a2008-11-13 22:59:24 +000077 {
Andrey Andreeveaa60c72012-11-06 01:11:22 +020078 $this->db =& $db;
Andrey Andreev24276a32012-01-08 02:44:38 +020079 log_message('debug', 'Database Utility Class Initialized');
Derek Allard2067d1a2008-11-13 22:59:24 +000080 }
81
82 // --------------------------------------------------------------------
83
84 /**
85 * List databases
86 *
Andrey Andreevb457a402012-04-09 16:11:56 +030087 * @return array
Derek Allard2067d1a2008-11-13 22:59:24 +000088 */
Andrey Andreev24276a32012-01-08 02:44:38 +020089 public function list_databases()
Barry Mienydd671972010-10-04 16:33:58 +020090 {
Derek Allard2067d1a2008-11-13 22:59:24 +000091 // Is there a cached result?
Andrey Andreev5d281762012-06-11 22:05:40 +030092 if (isset($this->db->data_cache['db_names']))
Derek Allard2067d1a2008-11-13 22:59:24 +000093 {
Andrey Andreev5d281762012-06-11 22:05:40 +030094 return $this->db->data_cache['db_names'];
Derek Allard2067d1a2008-11-13 22:59:24 +000095 }
Andrey Andreevb457a402012-04-09 16:11:56 +030096 elseif ($this->_list_databases === FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +000097 {
Andrey Andreev8d3afde2012-11-06 12:53:47 +020098 return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
Derek Allard2067d1a2008-11-13 22:59:24 +000099 }
Barry Mienydd671972010-10-04 16:33:58 +0200100
Andrey Andreev5d281762012-06-11 22:05:40 +0300101 $this->db->data_cache['db_names'] = array();
Andrey Andreevb457a402012-04-09 16:11:56 +0300102
103 $query = $this->db->query($this->_list_databases);
104 if ($query === FALSE)
105 {
Andrey Andreev5d281762012-06-11 22:05:40 +0300106 return $this->db->data_cache['db_names'];
Andrey Andreevb457a402012-04-09 16:11:56 +0300107 }
108
Andrey Andreev9e945762012-11-13 01:08:34 +0200109 for ($i = 0, $query = $query->result_array(), $c = count($query); $i < $c; $i++)
Andrey Andreevb457a402012-04-09 16:11:56 +0300110 {
Andrey Andreev9e945762012-11-13 01:08:34 +0200111 $this->db->data_cache['db_names'][] = current($query[$i]);
Andrey Andreevb457a402012-04-09 16:11:56 +0300112 }
113
Andrey Andreev5d281762012-06-11 22:05:40 +0300114 return $this->db->data_cache['db_names'];
Derek Allard2067d1a2008-11-13 22:59:24 +0000115 }
116
117 // --------------------------------------------------------------------
118
119 /**
Derek Allarde7f03252010-02-04 16:47:01 +0000120 * Determine if a particular database exists
121 *
Andrey Andreevae85eb42012-11-02 01:42:31 +0200122 * @param string $database_name
Andrey Andreevb457a402012-04-09 16:11:56 +0300123 * @return bool
Derek Allarde7f03252010-02-04 16:47:01 +0000124 */
Andrey Andreev24276a32012-01-08 02:44:38 +0200125 public function database_exists($database_name)
Derek Allard62396232010-02-04 17:45:47 +0000126 {
Andrey Andreevb457a402012-04-09 16:11:56 +0300127 return in_array($database_name, $this->list_databases());
Derek Allarde7f03252010-02-04 16:47:01 +0000128 }
129
130 // --------------------------------------------------------------------
131
132 /**
Derek Allard2067d1a2008-11-13 22:59:24 +0000133 * Optimize Table
134 *
Andrey Andreevae85eb42012-11-02 01:42:31 +0200135 * @param string $table_name
Andrey Andreevb457a402012-04-09 16:11:56 +0300136 * @return mixed
Derek Allard2067d1a2008-11-13 22:59:24 +0000137 */
Andrey Andreev24276a32012-01-08 02:44:38 +0200138 public function optimize_table($table_name)
Derek Allard2067d1a2008-11-13 22:59:24 +0000139 {
Andrey Andreevb457a402012-04-09 16:11:56 +0300140 if ($this->_optimize_table === FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000141 {
Andrey Andreev8d3afde2012-11-06 12:53:47 +0200142 return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
Derek Allard2067d1a2008-11-13 22:59:24 +0000143 }
Barry Mienydd671972010-10-04 16:33:58 +0200144
Andrey Andreevb457a402012-04-09 16:11:56 +0300145 $query = $this->db->query(sprintf($this->_optimize_table, $this->db->escape_identifiers($table_name)));
146 if ($query !== FALSE)
147 {
148 $query = $query->result_array();
Dimitar34cadee2012-11-24 13:13:07 +0200149 return current($query);
Andrey Andreevb457a402012-04-09 16:11:56 +0300150 }
Barry Mienydd671972010-10-04 16:33:58 +0200151
Andrey Andreevb457a402012-04-09 16:11:56 +0300152 return FALSE;
Derek Allard2067d1a2008-11-13 22:59:24 +0000153 }
154
155 // --------------------------------------------------------------------
156
157 /**
158 * Optimize Database
159 *
Andrey Andreevb457a402012-04-09 16:11:56 +0300160 * @return mixed
Derek Allard2067d1a2008-11-13 22:59:24 +0000161 */
Andrey Andreev24276a32012-01-08 02:44:38 +0200162 public function optimize_database()
Derek Allard2067d1a2008-11-13 22:59:24 +0000163 {
Andrey Andreevb457a402012-04-09 16:11:56 +0300164 if ($this->_optimize_table === FALSE)
165 {
Andrey Andreev8d3afde2012-11-06 12:53:47 +0200166 return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
Andrey Andreevb457a402012-04-09 16:11:56 +0300167 }
168
Derek Allard2067d1a2008-11-13 22:59:24 +0000169 $result = array();
170 foreach ($this->db->list_tables() as $table_name)
171 {
Andrey Andreevb457a402012-04-09 16:11:56 +0300172 $res = $this->db->query(sprintf($this->_optimize_table, $this->db->escape_identifiers($table_name)));
173 if (is_bool($res))
Derek Allard2067d1a2008-11-13 22:59:24 +0000174 {
Andrey Andreevb457a402012-04-09 16:11:56 +0300175 return $res;
Derek Allard2067d1a2008-11-13 22:59:24 +0000176 }
Barry Mienydd671972010-10-04 16:33:58 +0200177
Derek Allard2067d1a2008-11-13 22:59:24 +0000178 // Build the result array...
Andrey Andreevb457a402012-04-09 16:11:56 +0300179 $res = $res->result_array();
Derek Allard2067d1a2008-11-13 22:59:24 +0000180 $res = current($res);
181 $key = str_replace($this->db->database.'.', '', current($res));
182 $keys = array_keys($res);
183 unset($res[$keys[0]]);
Barry Mienydd671972010-10-04 16:33:58 +0200184
Derek Allard2067d1a2008-11-13 22:59:24 +0000185 $result[$key] = $res;
186 }
187
188 return $result;
189 }
190
191 // --------------------------------------------------------------------
192
193 /**
194 * Repair Table
195 *
Andrey Andreevae85eb42012-11-02 01:42:31 +0200196 * @param string $table_name
Andrey Andreevb457a402012-04-09 16:11:56 +0300197 * @return mixed
Derek Allard2067d1a2008-11-13 22:59:24 +0000198 */
Andrey Andreev24276a32012-01-08 02:44:38 +0200199 public function repair_table($table_name)
Derek Allard2067d1a2008-11-13 22:59:24 +0000200 {
Andrey Andreevb457a402012-04-09 16:11:56 +0300201 if ($this->_repair_table === FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000202 {
Andrey Andreev8d3afde2012-11-06 12:53:47 +0200203 return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
Derek Allard2067d1a2008-11-13 22:59:24 +0000204 }
Barry Mienydd671972010-10-04 16:33:58 +0200205
Andrey Andreevb457a402012-04-09 16:11:56 +0300206 $query = $this->db->query(sprintf($this->_repair_table, $this->db->escape_identifiers($table_name)));
207 if (is_bool($query))
208 {
209 return $query;
210 }
Barry Mienydd671972010-10-04 16:33:58 +0200211
Andrey Andreevb457a402012-04-09 16:11:56 +0300212 $query = $query->result_array();
213 return current($query);
Derek Allard2067d1a2008-11-13 22:59:24 +0000214 }
Barry Mienydd671972010-10-04 16:33:58 +0200215
Derek Allard2067d1a2008-11-13 22:59:24 +0000216 // --------------------------------------------------------------------
217
218 /**
219 * Generate CSV from a query result object
220 *
Andrey Andreevae85eb42012-11-02 01:42:31 +0200221 * @param object $query Query result object
222 * @param string $delim Delimiter (default: ,)
223 * @param string $newline Newline character (default: \n)
224 * @param string $enclosure Enclosure (default: ")
Derek Allard2067d1a2008-11-13 22:59:24 +0000225 * @return string
226 */
Andrey Andreev24276a32012-01-08 02:44:38 +0200227 public function csv_from_result($query, $delim = ',', $newline = "\n", $enclosure = '"')
Derek Allard2067d1a2008-11-13 22:59:24 +0000228 {
Derek Jones47874132009-02-10 17:32:15 +0000229 if ( ! is_object($query) OR ! method_exists($query, 'list_fields'))
Derek Allard2067d1a2008-11-13 22:59:24 +0000230 {
231 show_error('You must submit a valid result object');
Barry Mienydd671972010-10-04 16:33:58 +0200232 }
233
Derek Allard2067d1a2008-11-13 22:59:24 +0000234 $out = '';
Derek Allard2067d1a2008-11-13 22:59:24 +0000235 // First generate the headings from the table column names
236 foreach ($query->list_fields() as $name)
237 {
238 $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim;
239 }
Barry Mienydd671972010-10-04 16:33:58 +0200240
Andrey Andreev24276a32012-01-08 02:44:38 +0200241 $out = rtrim($out).$newline;
Barry Mienydd671972010-10-04 16:33:58 +0200242
Derek Allard2067d1a2008-11-13 22:59:24 +0000243 // Next blast through the result array and build out the rows
Andrey Andreevd06acd82012-05-25 00:29:09 +0300244 while ($row = $query->unbuffered_row('array'))
Derek Allard2067d1a2008-11-13 22:59:24 +0000245 {
246 foreach ($row as $item)
247 {
Barry Mienydd671972010-10-04 16:33:58 +0200248 $out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim;
Derek Allard2067d1a2008-11-13 22:59:24 +0000249 }
Andrey Andreev24276a32012-01-08 02:44:38 +0200250 $out = rtrim($out).$newline;
Derek Allard2067d1a2008-11-13 22:59:24 +0000251 }
252
253 return $out;
254 }
Barry Mienydd671972010-10-04 16:33:58 +0200255
Derek Allard2067d1a2008-11-13 22:59:24 +0000256 // --------------------------------------------------------------------
257
258 /**
259 * Generate XML data from a query result object
260 *
Andrey Andreevae85eb42012-11-02 01:42:31 +0200261 * @param object $query Query result object
262 * @param array $params Any preferences
Derek Allard2067d1a2008-11-13 22:59:24 +0000263 * @return string
264 */
Andrey Andreev24276a32012-01-08 02:44:38 +0200265 public function xml_from_result($query, $params = array())
Derek Allard2067d1a2008-11-13 22:59:24 +0000266 {
Pascal Kriete69b1fcc2009-08-24 16:42:52 +0000267 if ( ! is_object($query) OR ! method_exists($query, 'list_fields'))
Derek Allard2067d1a2008-11-13 22:59:24 +0000268 {
269 show_error('You must submit a valid result object');
270 }
Barry Mienydd671972010-10-04 16:33:58 +0200271
Derek Allard2067d1a2008-11-13 22:59:24 +0000272 // Set our default values
273 foreach (array('root' => 'root', 'element' => 'element', 'newline' => "\n", 'tab' => "\t") as $key => $val)
274 {
275 if ( ! isset($params[$key]))
276 {
277 $params[$key] = $val;
278 }
279 }
Barry Mienydd671972010-10-04 16:33:58 +0200280
Derek Allard2067d1a2008-11-13 22:59:24 +0000281 // Create variables for convenience
282 extract($params);
Barry Mienydd671972010-10-04 16:33:58 +0200283
Derek Allard2067d1a2008-11-13 22:59:24 +0000284 // Load the xml helper
285 $CI =& get_instance();
286 $CI->load->helper('xml');
287
288 // Generate the result
Andrey Andreevb457a402012-04-09 16:11:56 +0300289 $xml = '<'.$root.'>'.$newline;
Andrey Andreevd06acd82012-05-25 00:29:09 +0300290 while ($row = $query->unbuffered_row())
Derek Allard2067d1a2008-11-13 22:59:24 +0000291 {
Andrey Andreevb457a402012-04-09 16:11:56 +0300292 $xml .= $tab.'<'.$element.'>'.$newline;
Derek Allard2067d1a2008-11-13 22:59:24 +0000293 foreach ($row as $key => $val)
294 {
Andrey Andreevb457a402012-04-09 16:11:56 +0300295 $xml .= $tab.$tab.'<'.$key.'>'.xml_convert($val).'</'.$key.'>'.$newline;
Derek Allard2067d1a2008-11-13 22:59:24 +0000296 }
Andrey Andreevb457a402012-04-09 16:11:56 +0300297 $xml .= $tab.'</'.$element.'>'.$newline;
Derek Allard2067d1a2008-11-13 22:59:24 +0000298 }
Barry Mienydd671972010-10-04 16:33:58 +0200299
Andrey Andreevb457a402012-04-09 16:11:56 +0300300 return $xml.'</'.$root.'>'.$newline;
Derek Allard2067d1a2008-11-13 22:59:24 +0000301 }
302
303 // --------------------------------------------------------------------
304
305 /**
306 * Database Backup
307 *
Andrey Andreevae85eb42012-11-02 01:42:31 +0200308 * @param array $params
Derek Allard2067d1a2008-11-13 22:59:24 +0000309 * @return void
310 */
Andrey Andreev24276a32012-01-08 02:44:38 +0200311 public function backup($params = array())
Derek Allard2067d1a2008-11-13 22:59:24 +0000312 {
313 // If the parameters have not been submitted as an
314 // array then we know that it is simply the table
315 // name, which is a valid short cut.
316 if (is_string($params))
317 {
318 $params = array('tables' => $params);
319 }
Barry Mienydd671972010-10-04 16:33:58 +0200320
Derek Allard2067d1a2008-11-13 22:59:24 +0000321 // Set up our default preferences
322 $prefs = array(
Andrey Andreev24276a32012-01-08 02:44:38 +0200323 'tables' => array(),
324 'ignore' => array(),
325 'filename' => '',
326 'format' => 'gzip', // gzip, zip, txt
327 'add_drop' => TRUE,
328 'add_insert' => TRUE,
329 'newline' => "\n"
330 );
Derek Allard2067d1a2008-11-13 22:59:24 +0000331
332 // Did the user submit any preferences? If so set them....
333 if (count($params) > 0)
334 {
335 foreach ($prefs as $key => $val)
336 {
337 if (isset($params[$key]))
338 {
339 $prefs[$key] = $params[$key];
340 }
341 }
342 }
343
Barry Mienydd671972010-10-04 16:33:58 +0200344 // Are we backing up a complete database or individual tables?
Derek Allard2067d1a2008-11-13 22:59:24 +0000345 // If no table names were submitted we'll fetch the entire table list
Andrey Andreev24276a32012-01-08 02:44:38 +0200346 if (count($prefs['tables']) === 0)
Derek Allard2067d1a2008-11-13 22:59:24 +0000347 {
348 $prefs['tables'] = $this->db->list_tables();
349 }
Barry Mienydd671972010-10-04 16:33:58 +0200350
Derek Allard2067d1a2008-11-13 22:59:24 +0000351 // Validate the format
352 if ( ! in_array($prefs['format'], array('gzip', 'zip', 'txt'), TRUE))
353 {
354 $prefs['format'] = 'txt';
355 }
356
Andrey Andreev24276a32012-01-08 02:44:38 +0200357 // Is the encoder supported? If not, we'll either issue an
Derek Allard2067d1a2008-11-13 22:59:24 +0000358 // error or use plain text depending on the debug settings
Andrey Andreevb457a402012-04-09 16:11:56 +0300359 if (($prefs['format'] === 'gzip' && ! @function_exists('gzencode'))
360 OR ($prefs['format'] === 'zip' && ! @function_exists('gzcompress')))
Derek Allard2067d1a2008-11-13 22:59:24 +0000361 {
362 if ($this->db->db_debug)
363 {
Andrey Andreev8d3afde2012-11-06 12:53:47 +0200364 return $this->db->display_error('db_unsupported_compression');
Derek Allard2067d1a2008-11-13 22:59:24 +0000365 }
Barry Mienydd671972010-10-04 16:33:58 +0200366
Derek Allard2067d1a2008-11-13 22:59:24 +0000367 $prefs['format'] = 'txt';
368 }
369
Barry Mienydd671972010-10-04 16:33:58 +0200370 // Was a Zip file requested?
Andrey Andreev24276a32012-01-08 02:44:38 +0200371 if ($prefs['format'] === 'zip')
Derek Allard2067d1a2008-11-13 22:59:24 +0000372 {
Andrey Andreev24276a32012-01-08 02:44:38 +0200373 // Set the filename if not provided (only needed with Zip files)
Alex Bilbie48a2baf2012-06-02 11:09:54 +0100374 if ($prefs['filename'] === '')
Derek Allard2067d1a2008-11-13 22:59:24 +0000375 {
Andrey Andreev24276a32012-01-08 02:44:38 +0200376 $prefs['filename'] = (count($prefs['tables']) === 1 ? $prefs['tables'] : $this->db->database)
377 .date('Y-m-d_H-i', time()).'.sql';
Derek Allard2067d1a2008-11-13 22:59:24 +0000378 }
Andrey Andreev24276a32012-01-08 02:44:38 +0200379 else
Derek Allard2067d1a2008-11-13 22:59:24 +0000380 {
Andrey Andreev24276a32012-01-08 02:44:38 +0200381 // If they included the .zip file extension we'll remove it
382 if (preg_match('|.+?\.zip$|', $prefs['filename']))
383 {
384 $prefs['filename'] = str_replace('.zip', '', $prefs['filename']);
385 }
386
387 // Tack on the ".sql" file extension if needed
388 if ( ! preg_match('|.+?\.sql$|', $prefs['filename']))
389 {
390 $prefs['filename'] .= '.sql';
391 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000392 }
393
394 // Load the Zip class and output it
Derek Allard2067d1a2008-11-13 22:59:24 +0000395 $CI =& get_instance();
396 $CI->load->library('zip');
Barry Mienydd671972010-10-04 16:33:58 +0200397 $CI->zip->add_data($prefs['filename'], $this->_backup($prefs));
Derek Allard2067d1a2008-11-13 22:59:24 +0000398 return $CI->zip->get_zip();
399 }
Alex Bilbie48a2baf2012-06-02 11:09:54 +0100400 elseif ($prefs['format'] === 'txt') // Was a text file requested?
Andrey Andreev24276a32012-01-08 02:44:38 +0200401 {
402 return $this->_backup($prefs);
403 }
404 elseif ($prefs['format'] === 'gzip') // Was a Gzip file requested?
405 {
406 return gzencode($this->_backup($prefs));
407 }
Barry Mienydd671972010-10-04 16:33:58 +0200408
Andrey Andreev24276a32012-01-08 02:44:38 +0200409 return;
Derek Allard2067d1a2008-11-13 22:59:24 +0000410 }
411
412}
413
Derek Allard2067d1a2008-11-13 22:59:24 +0000414/* End of file DB_utility.php */
Timothy Warren215890b2012-03-20 09:38:16 -0400415/* Location: ./system/database/DB_utility.php */