summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-09-26 20:50:02 +0200
committeradmin <devnull@localhost>2006-09-26 20:50:02 +0200
commit31075cf97ac386686e679eb7b8aaf852fd12d838 (patch)
tree850091b47df9b205676f20a4af3febc67c6d7ca0
parent41a1685573aa0ede15a9bf7b373c36a0406fb19d (diff)
-rw-r--r--system/database/DB_utility.php33
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