diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 751646590df..106fba680b6 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -65,6 +65,7 @@ abstract class CI_DB_driver { public $queries = array(); public $query_times = array(); public $data_cache = array(); + public $function_prefix; public $trans_enabled = TRUE; public $trans_strict = TRUE; @@ -1182,23 +1183,35 @@ protected function _get_operator($str) * @param mixed any parameters needed by the function * @return mixed */ - public function call_function($function) + public function call_function($func) { - $driver = ($this->dbdriver === 'postgre') ? 'pg_' : $this->dbdriver.'_'; - - if (FALSE === strpos($driver, $function)) + // Procedural + if (isset($this->function_prefix)) { - $function = $driver.$function; - } + if (FALSE === strpos($func, $this->function_prefix)) + { + $func = $this->function_prefix.$func; + } - if ( ! function_exists($function)) + if ( ! function_exists($func)) + { + return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE; + } + } + else + // OOP { - return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE; + if ( ! method_exists($this->conn_id, $func)) + { + return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE; + } + + $func = array($this->conn_id, $func); } return (func_num_args() > 1) - ? call_user_func_array($function, array_splice(func_get_args(), 1)) - : call_user_func($function); + ? call_user_func_array($func, array_splice(func_get_args(), 1)) + : call_user_func($func); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/native_driver.php b/system/database/drivers/native_driver.php index 81fc66cd1d8..f7cd8398994 100644 --- a/system/database/drivers/native_driver.php +++ b/system/database/drivers/native_driver.php @@ -40,8 +40,6 @@ */ abstract class CI_DB_native_driver extends CI_DB { - public $function_prefix; - // The character used to escaping protected $_escape_char = '"'; diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 68719efa704..08216a98297 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -137,8 +137,8 @@ Release Date: Not Released - Added PDO support for create_database(), drop_database and drop_table() in :doc:`Database Forge `. - Added unbuffered_row() method for getting a row without prefetching whole result (consume less memory). - Added PDO support for ``list_fields()`` in :doc:`Database Results `. - - Added capability for packages to hold database.php config files - - Added subdrivers support (currently only used by PDO). + - Added capability for packages to hold database.php config files. + - Added OOP support for the ``call_function()`` method (used by SQLite3, PDO). - Libraries @@ -316,6 +316,7 @@ Bug fixes for 3.0 - Fixed a bug (#135) - PHP Error logging was impossible without the errors being displayed. - Fixed a bug (#1613) - :doc:`Form Helper ` functions ``form_multiselect()``, ``form_dropdown()`` didn't properly handle empty array option groups. - Fixed a bug (#1605) - :doc:`Pagination Library ` produced incorrect *previous* and *next* link values. +- Fixed a bug in :doc:`Database method call_function() ` where it failed with the OCI8 and PDO drivers. Version 2.1.2 =============