Skip to content

Commit

Permalink
Fix call_function() for the native PostgreSQL, Oracle drivers and imp…
Browse files Browse the repository at this point in the history
…lement logic for method calls
  • Loading branch information
narfbg committed Jul 23, 2012
1 parent 53d82a9 commit 81a3d54
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
33 changes: 23 additions & 10 deletions system/database/DB_driver.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

// --------------------------------------------------------------------
Expand Down
2 changes: 0 additions & 2 deletions system/database/drivers/native_driver.php
Expand Up @@ -40,8 +40,6 @@
*/
abstract class CI_DB_native_driver extends CI_DB {

public $function_prefix;

// The character used to escaping
protected $_escape_char = '"';

Expand Down
5 changes: 3 additions & 2 deletions user_guide_src/source/changelog.rst
Expand Up @@ -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

Expand Down Expand Up @@ -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
=============
Expand Down

0 comments on commit 81a3d54

Please sign in to comment.