diff options
author | admin <devnull@localhost> | 2006-09-26 20:50:02 +0200 |
---|---|---|
committer | admin <devnull@localhost> | 2006-09-26 20:50:02 +0200 |
commit | 31075cf97ac386686e679eb7b8aaf852fd12d838 (patch) | |
tree | 850091b47df9b205676f20a4af3febc67c6d7ca0 /system/database/DB_utility.php | |
parent | 41a1685573aa0ede15a9bf7b373c36a0406fb19d (diff) |
Diffstat (limited to 'system/database/DB_utility.php')
-rw-r--r-- | system/database/DB_utility.php | 33 |
1 files changed, 33 insertions, 0 deletions
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 @@ -188,6 +188,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 * * @access public |