From 31075cf97ac386686e679eb7b8aaf852fd12d838 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 26 Sep 2006 18:50:02 +0000 Subject: --- system/database/DB_utility.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'system/database/DB_utility.php') diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php index 00e20c6c6..281a3b87d 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -187,6 +187,39 @@ class CI_DB_utility { // -------------------------------------------------------------------- + /** + * Optimize Database + * + * @access public + * @param string the table name + * @return bool + */ + function optimize_database() + { + $result = array(); + foreach ($this->list_tables() as $table_name) + { + $sql = $this->_optimize_table($table_name); + + if (is_bool($sql)) + { + return $sql; + } + + $query = $this->db->query($sql); + $res = current($query->result_array()); + $key = str_replace($this->db->database.'.', '', current($res)); + $keys = array_keys($res); + unset($res[$keys[0]]); + + $result[$key] = $res; + } + + return $result; + } + + // -------------------------------------------------------------------- + /** * Optimize Table * -- cgit v1.2.3-24-g4f1b