summaryrefslogtreecommitdiffstats
path: root/system/database/DB_utility.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/database/DB_utility.php')
-rw-r--r--system/database/DB_utility.php114
1 files changed, 71 insertions, 43 deletions
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php
index 36d74c5b3..950db7dfd 100644
--- a/system/database/DB_utility.php
+++ b/system/database/DB_utility.php
@@ -65,6 +65,30 @@ class CI_DB_utility {
// --------------------------------------------------------------------
/**
+ * Primary
+ *
+ * Retrieves the primary key. It assumes that the row in the first
+ * position is the primary key
+ *
+ * @access public
+ * @param string the table name
+ * @return string
+ */
+ function primary($table = '')
+ {
+ $fields = $this->field_names($table);
+
+ if ( ! is_array($fields))
+ {
+ return FALSE;
+ }
+
+ return current($fields);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Returns an array of table names
*
* @access public
@@ -188,39 +212,15 @@ class CI_DB_utility {
// --------------------------------------------------------------------
/**
- * Primary
- *
- * Retrieves the primary key. It assumes that the row in the first
- * position is the primary key
- *
- * @access public
- * @param string the table name
- * @return string
- */
- function primary($table = '')
- {
- $fields = $this->field_names($table);
-
- if ( ! is_array($fields))
- {
- return FALSE;
- }
-
- return current($fields);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Create database
*
* @access public
* @param string the database name
* @return bool
*/
- function create_database($name)
+ function create_database($db_name)
{
- $sql = $this->_create_database($name);
+ $sql = $this->_create_database($db_name);
if (is_bool($sql))
{
@@ -239,9 +239,9 @@ class CI_DB_utility {
* @param string the database name
* @return bool
*/
- function drop_database($name)
+ function drop_database($db_name)
{
- $sql = $this->_drop_database($name);
+ $sql = $this->_drop_database($db_name);
if (is_bool($sql))
{
@@ -273,48 +273,76 @@ class CI_DB_utility {
return $dbs;
}
-
+
// --------------------------------------------------------------------
/**
- * Drop Table
+ * Optimize Table
*
* @access public
* @param string the table name
* @return bool
*/
- function drop_table($name)
+ function optimize_table($table_name)
{
- $sql = $this->_drop_table($name);
+ $sql = $this->_optimize_table($table_name);
if (is_bool($sql))
{
return $sql;
}
- return $this->db->query($sql);
+ $query = $this->db->query($sql);
+ return current($query->result_array());
}
+ // --------------------------------------------------------------------
-
- function alter_table()
+ /**
+ * Optimize Table
+ *
+ * @access public
+ * @param string the table name
+ * @return bool
+ */
+
+ function repair_table($table_name)
{
- }
+ $sql = $this->_repair_table($table_name);
+
+ if (is_bool($sql))
+ {
+ return $sql;
+ }
- function create_index()
- {
+ $query = $this->db->query($sql);
+ return current($query->result_array());
}
-
- function drop_index()
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop Table
+ *
+ * @access public
+ * @param string the table name
+ * @return bool
+ */
+ function drop_table($table_name)
{
- }
+ $sql = $this->_drop_table($table_name);
+
+ if (is_bool($sql))
+ {
+ return $sql;
+ }
- function optimize()
- {
+ return $this->db->query($sql);
}
+
}
?> \ No newline at end of file