diff options
author | Timothy Warren <tim@timshomepage.net> | 2012-03-02 15:29:27 +0100 |
---|---|---|
committer | Timothy Warren <tim@timshomepage.net> | 2012-03-02 15:29:27 +0100 |
commit | 6a3bda6a1fee45635f66f4e22d288f73334e9e48 (patch) | |
tree | 9a4a785e31daa46465e08a0b60ba7d076df04d6a /system/database/drivers/mysqli | |
parent | 2d04624cb59d5852f8e61d610ab822252cad685a (diff) | |
parent | 06400c0397793132e7517a1e414d104800e16667 (diff) |
Merge branch 'develop' of git://github.com/EllisLab/CodeIgniter into develop
Diffstat (limited to 'system/database/drivers/mysqli')
-rw-r--r-- | system/database/drivers/mysqli/mysqli_driver.php | 37 | ||||
-rw-r--r-- | system/database/drivers/mysqli/mysqli_result.php | 19 |
2 files changed, 28 insertions, 28 deletions
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index a79b2a4ad..031371345 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -119,11 +119,23 @@ class CI_DB_mysqli_driver extends CI_DB { /** * Select the database * + * @param string database name * @return bool */ - public function db_select() + public function db_select($database = '') { - return @mysqli_select_db($this->conn_id, $this->database); + if ($database === '') + { + $database = $this->database; + } + + if (@mysqli_select_db($this->conn_id, $database)) + { + $this->database = $database; + return TRUE; + } + + return FALSE; } // -------------------------------------------------------------------- @@ -406,25 +418,16 @@ class CI_DB_mysqli_driver extends CI_DB { // -------------------------------------------------------------------- /** - * The error message string + * Error * - * @return string - */ - protected function _error_message() - { - return mysqli_error($this->conn_id); - } - - // -------------------------------------------------------------------- - - /** - * The error message number + * Returns an array containing code and message of the last + * database error that has occured. * - * @return int + * @return array */ - protected function _error_number() + public function error() { - return mysqli_errno($this->conn_id); + return array('code' => mysqli_errno($this->conn_id), 'message' => mysqli_error($this->conn_id)); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php index 0a50cccac..8b909cc56 100644 --- a/system/database/drivers/mysqli/mysqli_result.php +++ b/system/database/drivers/mysqli/mysqli_result.php @@ -90,18 +90,15 @@ class CI_DB_mysqli_result extends CI_DB_result { public function field_data() { $retval = array(); - while ($field = mysqli_fetch_object($this->result_id)) + $field_data = mysqli_fetch_fields($this->result_id); + for ($i = 0, $c = count($field_data); $i < $c; $i++) { - preg_match('/([a-zA-Z]+)(\(\d+\))?/', $field->Type, $matches); - - $F = new stdClass(); - $F->name = $field->Field; - $F->type = ( ! empty($matches[1])) ? $matches[1] : NULL; - $F->default = $field->Default; - $F->max_length = ( ! empty($matches[2])) ? preg_replace('/[^\d]/', '', $matches[2]) : NULL; - $F->primary_key = (int) ($field->Key === 'PRI'); - - $retval[] = $F; + $retval[$i] = new stdClass(); + $retval[$i]->name = $field_data[$i]->name; + $retval[$i]->type = $field_data[$i]->type; + $retval[$i]->max_length = $field_data[$i]->max_length; + $retval[$i]->primary_key = (int) ($field_data[$i]->flags & 2); + $retval[$i]->default = ''; } return $retval; |