From ab4f61bacfa022c0c7238e9661ad9cb2ac440d95 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 25 Sep 2006 22:12:32 +0000 Subject: --- system/database/DB_utility.php | 114 +++++++++++++++++++++++++---------------- 1 file changed, 71 insertions(+), 43 deletions(-) (limited to 'system/database/DB_utility.php') 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 @@ -64,6 +64,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 * @@ -187,30 +211,6 @@ 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 * @@ -218,9 +218,9 @@ class CI_DB_utility { * @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 -- cgit v1.2.3-24-g4f1b