From 6ea08e60670e4bb7ce184b695d515626d472489d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 5 Jan 2012 21:43:17 +0200 Subject: Fix issue 413 --- system/database/drivers/oci8/oci8_driver.php | 29 ++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index cc9557e7d..dea08ffe4 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -528,8 +528,7 @@ class CI_DB_oci8_driver extends CI_DB { */ protected function _error_message() { - // If the error was during connection, no conn_id should be passed - $error = is_resource($this->conn_id) ? oci_error($this->conn_id) : oci_error(); + $error = self::_get_error_data(); return $error['message']; } @@ -542,13 +541,35 @@ class CI_DB_oci8_driver extends CI_DB { */ protected function _error_number() { - // Same as _error_message() - $error = is_resource($this->conn_id) ? oci_error($this->conn_id) : oci_error(); + $error = self::_get_error_data(); return $error['code']; } // -------------------------------------------------------------------- + /* Get error data + * + * Used by _error_message() and _error_number() + * + * @return array + */ + private function _get_error_data() + { + $res = NULL; + foreach (array('curs_id', 'stmt_id', 'conn_id') as $key) + { + if (is_resource($this->$key)) + { + $res = $key; + break; + } + } + + return ( ! is_null($res)) ? oci_error($res) : oci_error(); + } + + // -------------------------------------------------------------------- + /** * Escape the SQL Identifiers * -- cgit v1.2.3-24-g4f1b