Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix call_function() for the native PostgreSQL, Oracle drivers and imp…

…lement logic for method calls
  • Loading branch information...
commit 81a3d54465082afd321a89ca2fcf1982cd2b2a13 1 parent 53d82a9
@narfbg narfbg authored
View
33 system/database/DB_driver.php
@@ -65,6 +65,7 @@
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);
}
// --------------------------------------------------------------------
View
2  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 = '"';
View
5 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 <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 <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 <helpers/form_helper>` functions ``form_multiselect()``, ``form_dropdown()`` didn't properly handle empty array option groups.
- Fixed a bug (#1605) - :doc:`Pagination Library <libraries/pagination>` produced incorrect *previous* and *next* link values.
+- Fixed a bug in :doc:`Database method call_function() <database/call_function>` where it failed with the OCI8 and PDO drivers.
Version 2.1.2
=============
Please sign in to comment.
Something went wrong with that request. Please try again.