summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/oci8/oci8_driver.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/database/drivers/oci8/oci8_driver.php')
-rw-r--r--system/database/drivers/oci8/oci8_driver.php116
1 files changed, 59 insertions, 57 deletions
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index 1cf063ec1..9f969f9a8 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -35,8 +35,6 @@
* This is a modification of the DB_driver class to
* permit access to oracle databases
*
- * NOTE: this uses the PHP 4 oci methods
- *
* @author Kelly McArdle
*
*/
@@ -77,9 +75,9 @@ class CI_DB_oci8_driver extends CI_DB {
* @access private called by the base class
* @return resource
*/
- function db_connect()
+ public function db_connect()
{
- return @ocilogon($this->username, $this->password, $this->hostname, $this->char_set);
+ return @oci_connect($this->username, $this->password, $this->hostname, $this->char_set);
}
// --------------------------------------------------------------------
@@ -90,9 +88,9 @@ class CI_DB_oci8_driver extends CI_DB {
* @access private called by the base class
* @return resource
*/
- function db_pconnect()
+ public function db_pconnect()
{
- return @ociplogon($this->username, $this->password, $this->hostname, $this->char_set);
+ return @oci_pconnect($this->username, $this->password, $this->hostname, $this->char_set);
}
// --------------------------------------------------------------------
@@ -106,9 +104,10 @@ class CI_DB_oci8_driver extends CI_DB {
* @access public
* @return void
*/
- function reconnect()
+ public function reconnect()
{
// not implemented in oracle
+ return;
}
// --------------------------------------------------------------------
@@ -119,8 +118,9 @@ class CI_DB_oci8_driver extends CI_DB {
* @access private called by the base class
* @return resource
*/
- function db_select()
+ public function db_select()
{
+ // Not in Oracle - schemas are actually usernames
return TRUE;
}
@@ -134,7 +134,7 @@ class CI_DB_oci8_driver extends CI_DB {
* @param string
* @return resource
*/
- function db_set_charset($charset, $collation)
+ public function db_set_charset($charset, $collation)
{
// this is done upon connect
return TRUE;
@@ -148,9 +148,9 @@ class CI_DB_oci8_driver extends CI_DB {
* @access public
* @return string
*/
- function _version()
+ public function _version()
{
- return ociserverversion($this->conn_id);
+ return oci_server_version($this->conn_id);
}
// --------------------------------------------------------------------
@@ -158,18 +158,18 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Execute the query
*
- * @access private called by the base class
+ * @access public called by the base class
* @param string an SQL query
* @return resource
*/
- function _execute($sql)
+ public function _execute($sql)
{
// oracle must parse the query before it is run. All of the actions with
// the query are based on the statement id returned by ociparse
$this->stmt_id = FALSE;
$this->_set_stmt_id($sql);
- ocisetprefetch($this->stmt_id, 1000);
- return @ociexecute($this->stmt_id, $this->_commit);
+ oci_set_prefetch($this->stmt_id, 1000);
+ return @oci_execute($this->stmt_id, $this->_commit);
}
/**
@@ -179,11 +179,11 @@ class CI_DB_oci8_driver extends CI_DB {
* @param string an SQL query
* @return none
*/
- function _set_stmt_id($sql)
+ private function _set_stmt_id($sql)
{
if ( ! is_resource($this->stmt_id))
{
- $this->stmt_id = ociparse($this->conn_id, $this->_prep_query($sql));
+ $this->stmt_id = oci_parse($this->conn_id, $this->_prep_query($sql));
}
}
@@ -198,7 +198,7 @@ class CI_DB_oci8_driver extends CI_DB {
* @param string an SQL query
* @return string
*/
- function _prep_query($sql)
+ private function _prep_query($sql)
{
return $sql;
}
@@ -211,9 +211,9 @@ class CI_DB_oci8_driver extends CI_DB {
* @access public
* @return cursor id
*/
- function get_cursor()
+ public function get_cursor()
{
- $this->curs_id = ocinewcursor($this->conn_id);
+ $this->curs_id = oci_new_cursor($this->conn_id);
return $this->curs_id;
}
@@ -237,7 +237,7 @@ class CI_DB_oci8_driver extends CI_DB {
* type yes the type of the parameter
* length yes the max size of the parameter
*/
- function stored_procedure($package, $procedure, $params)
+ public function stored_procedure($package, $procedure, $params)
{
if ($package == '' OR $procedure == '' OR ! is_array($params))
{
@@ -257,7 +257,7 @@ class CI_DB_oci8_driver extends CI_DB {
{
$sql .= $param['name'] . ",";
- if (array_key_exists('type', $param) && ($param['type'] == OCI_B_CURSOR))
+ if (array_key_exists('type', $param) && ($param['type'] === OCI_B_CURSOR))
{
$have_cursor = TRUE;
}
@@ -278,7 +278,7 @@ class CI_DB_oci8_driver extends CI_DB {
* @access private
* @return none
*/
- function _bind_params($params)
+ private function _bind_params($params)
{
if ( ! is_array($params) OR ! is_resource($this->stmt_id))
{
@@ -295,7 +295,7 @@ class CI_DB_oci8_driver extends CI_DB {
}
}
- ocibindbyname($this->stmt_id, $param['name'], $param['value'], $param['length'], $param['type']);
+ oci_bind_by_name($this->stmt_id, $param['name'], $param['value'], $param['length'], $param['type']);
}
}
@@ -307,7 +307,7 @@ class CI_DB_oci8_driver extends CI_DB {
* @access public
* @return bool
*/
- function trans_begin($test_mode = FALSE)
+ public function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
@@ -337,7 +337,7 @@ class CI_DB_oci8_driver extends CI_DB {
* @access public
* @return bool
*/
- function trans_commit()
+ public function trans_commit()
{
if ( ! $this->trans_enabled)
{
@@ -350,7 +350,7 @@ class CI_DB_oci8_driver extends CI_DB {
return TRUE;
}
- $ret = OCIcommit($this->conn_id);
+ $ret = oci_commit($this->conn_id);
$this->_commit = OCI_COMMIT_ON_SUCCESS;
return $ret;
}
@@ -363,7 +363,7 @@ class CI_DB_oci8_driver extends CI_DB {
* @access public
* @return bool
*/
- function trans_rollback()
+ public function trans_rollback()
{
if ( ! $this->trans_enabled)
{
@@ -376,7 +376,7 @@ class CI_DB_oci8_driver extends CI_DB {
return TRUE;
}
- $ret = OCIrollback($this->conn_id);
+ $ret = oci_rollback($this->conn_id);
$this->_commit = OCI_COMMIT_ON_SUCCESS;
return $ret;
}
@@ -391,7 +391,7 @@ class CI_DB_oci8_driver extends CI_DB {
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
- function escape_str($str, $like = FALSE)
+ public function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
@@ -425,9 +425,9 @@ class CI_DB_oci8_driver extends CI_DB {
* @access public
* @return integer
*/
- function affected_rows()
+ public function affected_rows()
{
- return @ocirowcount($this->stmt_id);
+ return @oci_num_rows($this->stmt_id);
}
// --------------------------------------------------------------------
@@ -438,7 +438,7 @@ class CI_DB_oci8_driver extends CI_DB {
* @access public
* @return integer
*/
- function insert_id()
+ public function insert_id()
{
// not supported in oracle
return $this->display_error('db_unsupported_function');
@@ -456,7 +456,7 @@ class CI_DB_oci8_driver extends CI_DB {
* @param string
* @return string
*/
- function count_all($table = '')
+ public function count_all($table = '')
{
if ($table == '')
{
@@ -482,11 +482,11 @@ class CI_DB_oci8_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @access private
+ * @access public
* @param boolean
- * @return string
+ * @return string
*/
- function _list_tables($prefix_limit = FALSE)
+ public function _list_tables($prefix_limit = FALSE)
{
$sql = "SELECT TABLE_NAME FROM ALL_TABLES";
@@ -509,7 +509,7 @@ class CI_DB_oci8_driver extends CI_DB {
* @param string the table name
* @return string
*/
- function _list_columns($table = '')
+ public function _list_columns($table = '')
{
return "SELECT COLUMN_NAME FROM all_tab_columns WHERE table_name = '$table'";
}
@@ -525,7 +525,7 @@ class CI_DB_oci8_driver extends CI_DB {
* @param string the table name
* @return object
*/
- function _field_data($table)
+ public function _field_data($table)
{
return "SELECT * FROM ".$table." where rownum = 1";
}
@@ -535,12 +535,13 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* The error message string
*
- * @access private
+ * @access public
* @return string
*/
- function _error_message()
+ public function _error_message()
{
- $error = ocierror($this->conn_id);
+ // 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();
return $error['message'];
}
@@ -549,12 +550,13 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* The error message number
*
- * @access private
+ * @access public
* @return integer
*/
- function _error_number()
+ public function _error_number()
{
- $error = ocierror($this->conn_id);
+ // Same as _error_message()
+ $error = is_resource($this->conn_id) ? oci_error($this->conn_id) : oci_error();
return $error['code'];
}
@@ -565,11 +567,11 @@ class CI_DB_oci8_driver extends CI_DB {
*
* This function escapes column and table names
*
- * @access private
+ * @access public
* @param string
* @return string
*/
- function _escape_identifiers($item)
+ public function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
@@ -612,7 +614,7 @@ class CI_DB_oci8_driver extends CI_DB {
* @param type
* @return type
*/
- function _from_tables($tables)
+ public function _from_tables($tables)
{
if ( ! is_array($tables))
{
@@ -635,9 +637,9 @@ class CI_DB_oci8_driver extends CI_DB {
* @param array the insert values
* @return string
*/
- function _insert($table, $keys, $values)
+ public function _insert($table, $keys, $values)
{
- return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
+ return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
// --------------------------------------------------------------------
@@ -653,7 +655,7 @@ class CI_DB_oci8_driver extends CI_DB {
* @param array the insert values
* @return string
*/
- function _insert_batch($table, $keys, $values)
+ public function _insert_batch($table, $keys, $values)
{
$keys = implode(', ', $keys);
$sql = "INSERT ALL\n";
@@ -683,7 +685,7 @@ class CI_DB_oci8_driver extends CI_DB {
* @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
+ public function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
@@ -716,7 +718,7 @@ class CI_DB_oci8_driver extends CI_DB {
* @param string the table name
* @return string
*/
- function _truncate($table)
+ public function _truncate($table)
{
return "TRUNCATE TABLE ".$table;
}
@@ -734,7 +736,7 @@ class CI_DB_oci8_driver extends CI_DB {
* @param string the limit clause
* @return string
*/
- function _delete($table, $where = array(), $like = array(), $limit = FALSE)
+ public function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
@@ -768,7 +770,7 @@ class CI_DB_oci8_driver extends CI_DB {
* @param integer the offset value
* @return string
*/
- function _limit($sql, $limit, $offset)
+ public function _limit($sql, $limit, $offset)
{
$limit = $offset + $limit;
$newsql = "SELECT * FROM (select inner_query.*, rownum rnum FROM ($sql) inner_query WHERE rownum < $limit)";
@@ -793,9 +795,9 @@ class CI_DB_oci8_driver extends CI_DB {
* @param resource
* @return void
*/
- function _close($conn_id)
+ public function _close($conn_id)
{
- @ocilogoff($conn_id);
+ @oci_close($conn_id);
}