

Public Member Functions | |
| db_connect () | |
| Non-persistent database connection. | |
| db_pconnect () | |
| Persistent database connection. | |
| db_select () | |
| Select the database. | |
| db_set_charset ($charset, $collation) | |
| Set client character set. | |
| _version () | |
| Version number query string. | |
| _execute ($sql) | |
| Execute the query. | |
| _set_stmt_id ($sql) | |
| Generate a statement ID. | |
| _prep_query ($sql) | |
| Prep the query. | |
| get_cursor () | |
| getCursor. | |
| stored_procedure ($package, $procedure, $params) | |
| Stored Procedure. | |
| _bind_params ($params) | |
| Bind parameters. | |
| trans_begin ($test_mode=FALSE) | |
| Begin Transaction. | |
| trans_commit () | |
| Commit Transaction. | |
| trans_rollback () | |
| Rollback Transaction. | |
| escape_str ($str) | |
| Escape String. | |
| affected_rows () | |
| Affected Rows. | |
| insert_id () | |
| Insert ID. | |
| count_all ($table= '') | |
| "Count All" query | |
| _list_tables ($prefix_limit=FALSE) | |
| Show table query. | |
| _list_columns ($table= '') | |
| Show column query. | |
| _field_data ($table) | |
| Field data query. | |
| _error_message () | |
| The error message string. | |
| _error_number () | |
| The error message number. | |
| _escape_table ($table) | |
| Escape Table Name. | |
| _protect_identifiers ($item, $first_word_only=FALSE) | |
| Protect Identifiers. | |
| _from_tables ($tables) | |
| From Tables. | |
| _insert ($table, $keys, $values) | |
| Insert statement. | |
| _update ($table, $values, $where, $orderby=array(), $limit=FALSE) | |
| Update statement. | |
| _truncate ($table) | |
| Truncate statement. | |
| _delete ($table, $where=array(), $like=array(), $limit=FALSE) | |
| Delete statement. | |
| _limit ($sql, $limit, $offset) | |
| Limit string. | |
| _close ($conn_id) | |
| Close DB Connection. | |
Public Attributes | |
| $_count_string = "SELECT COUNT(1) AS " | |
| The syntax to count rows is slightly different across different database engines, so this string appears in each driver and is used for the count_all() and count_all_results() functions. | |
| $_random_keyword = ' ASC' | |
| $_commit = OCI_COMMIT_ON_SUCCESS | |
| $stmt_id | |
| $curs_id | |
| $limit_used | |
This is a modification of the DB_driver class to permit access to oracle databases
NOTE: this uses the PHP 4 oci methods
Definition at line 44 of file oci8_driver.php.
| CI_DB_oci8_driver::_bind_params | ( | $ | params | ) |
Bind parameters.
private
Definition at line 255 of file oci8_driver.php.
Referenced by stored_procedure().
00256 { 00257 if ( ! is_array($params) OR ! is_resource($this->stmt_id)) 00258 { 00259 return; 00260 } 00261 00262 foreach ($params as $param) 00263 { 00264 foreach (array('name', 'value', 'type', 'length') as $val) 00265 { 00266 if ( ! isset($param[$val])) 00267 { 00268 $param[$val] = ''; 00269 } 00270 } 00271 00272 ocibindbyname($this->stmt_id, $param['name'], $param['value'], $param['length'], $param['type']); 00273 } 00274 }

| CI_DB_oci8_driver::_close | ( | $ | conn_id | ) |
Close DB Connection.
public
| resource |
Definition at line 755 of file oci8_driver.php.
| CI_DB_oci8_driver::_delete | ( | $ | table, | |
| $ | where = array(), |
|||
| $ | like = array(), |
|||
| $ | limit = FALSE | |||
| ) |
Delete statement.
Generates a platform-specific delete string from the supplied data
public
| string | the table name | |
| array | the where clause | |
| string | the limit clause |
Definition at line 696 of file oci8_driver.php.
00697 { 00698 $conditions = ''; 00699 00700 if (count($where) > 0 OR count($like) > 0) 00701 { 00702 $conditions = "\nWHERE "; 00703 $conditions .= implode("\n", $this->ar_where); 00704 00705 if (count($where) > 0 && count($like) > 0) 00706 { 00707 $conditions .= " AND "; 00708 } 00709 $conditions .= implode("\n", $like); 00710 } 00711 00712 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; 00713 00714 return "DELETE FROM ".$table.$conditions.$limit; 00715 }
| CI_DB_oci8_driver::_error_message | ( | ) |
| CI_DB_oci8_driver::_error_number | ( | ) |
| CI_DB_oci8_driver::_escape_table | ( | $ | table | ) |
Escape Table Name.
This function adds backticks if the table name has a period in it. Some DBs will get cranky unless periods are escaped
private
| string | the table name |
Definition at line 522 of file oci8_driver.php.
00523 { 00524 if (strpos($table, '.') !== FALSE) 00525 { 00526 $table = '"' . str_replace('.', '"."', $table) . '"'; 00527 } 00528 00529 return $table; 00530 }
| CI_DB_oci8_driver::_execute | ( | $ | sql | ) |
Execute the query.
private called by the base class
| string | an SQL query |
Definition at line 140 of file oci8_driver.php.
References _set_stmt_id().
00141 { 00142 // oracle must parse the query before it is run. All of the actions with 00143 // the query are based on the statement id returned by ociparse 00144 $this->_set_stmt_id($sql); 00145 ocisetprefetch($this->stmt_id, 1000); 00146 return @ociexecute($this->stmt_id, $this->_commit); 00147 }

| CI_DB_oci8_driver::_field_data | ( | $ | table | ) |
Field data query.
Generates a platform-specific query so that the column data can be retrieved
public
| string | the table name |
Definition at line 477 of file oci8_driver.php.
| CI_DB_oci8_driver::_from_tables | ( | $ | tables | ) |
From Tables.
This function implicitly groups FROM tables so there is no confusion about operator precedence in harmony with SQL standards
public
| type |
Definition at line 604 of file oci8_driver.php.
00605 { 00606 if ( ! is_array($tables)) 00607 { 00608 $tables = array($tables); 00609 } 00610 00611 return implode(', ', $tables); 00612 }
| CI_DB_oci8_driver::_insert | ( | $ | table, | |
| $ | keys, | |||
| $ | values | |||
| ) |
Insert statement.
Generates a platform-specific insert string from the supplied data
public
| string | the table name | |
| array | the insert keys | |
| array | the insert values |
Definition at line 627 of file oci8_driver.php.
00628 { 00629 return "INSERT INTO ".$this->_escape_table($table)." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; 00630 }
| CI_DB_oci8_driver::_limit | ( | $ | sql, | |
| $ | limit, | |||
| $ | offset | |||
| ) |
Limit string.
Generates a platform-specific LIMIT clause
public
| string | the sql query string | |
| integer | the number of rows to limit the query to | |
| integer | the offset value |
Definition at line 730 of file oci8_driver.php.
00731 { 00732 $limit = $offset + $limit; 00733 $newsql = "SELECT * FROM (select inner_query.*, rownum rnum FROM ($sql) inner_query WHERE rownum < $limit)"; 00734 00735 if ($offset != 0) 00736 { 00737 $newsql .= " WHERE rnum >= $offset"; 00738 } 00739 00740 // remember that we used limits 00741 $this->limit_used = TRUE; 00742 00743 return $newsql; 00744 }
| CI_DB_oci8_driver::_list_columns | ( | $ | table = '' |
) |
Show column query.
Generates a platform-specific query string so that the column names can be fetched
public
| string | the table name |
Definition at line 461 of file oci8_driver.php.
| CI_DB_oci8_driver::_list_tables | ( | $ | prefix_limit = FALSE |
) |
Show table query.
Generates a platform-specific query string so that the table names can be fetched
private
| boolean |
Definition at line 438 of file oci8_driver.php.
00439 { 00440 $sql = "SELECT TABLE_NAME FROM ALL_TABLES"; 00441 00442 if ($prefix_limit !== FALSE AND $this->dbprefix != '') 00443 { 00444 $sql .= " WHERE TABLE_NAME LIKE '".$this->dbprefix."%'"; 00445 } 00446 00447 return $sql; 00448 }
| CI_DB_oci8_driver::_prep_query | ( | $ | sql | ) |
Prep the query.
If needed, each database adapter can prep the query string
private called by execute()
| string | an SQL query |
Definition at line 175 of file oci8_driver.php.
Referenced by _set_stmt_id().

| CI_DB_oci8_driver::_protect_identifiers | ( | $ | item, | |
| $ | first_word_only = FALSE | |||
| ) |
Protect Identifiers.
This function adds backticks if appropriate based on db type
private
| mixed | the item to escape | |
| boolean | only affect the first word |
Definition at line 544 of file oci8_driver.php.
Referenced by count_all().
00545 { 00546 if (is_array($item)) 00547 { 00548 $escaped_array = array(); 00549 00550 foreach($item as $k=>$v) 00551 { 00552 $escaped_array[$this->_protect_identifiers($k)] = $this->_protect_identifiers($v, $first_word_only); 00553 } 00554 00555 return $escaped_array; 00556 } 00557 00558 // This function may get "item1 item2" as a string, and so 00559 // we may need ""item1" "item2"" and not ""item1 item2"" 00560 if (ctype_alnum($item) === FALSE) 00561 { 00562 if (strpos($item, '.') !== FALSE) 00563 { 00564 $aliased_tables = implode(".",$this->ar_aliased_tables).'.'; 00565 $table_name = substr($item, 0, strpos($item, '.')+1); 00566 $item = (strpos($aliased_tables, $table_name) !== FALSE) ? $item = $item : $this->dbprefix.$item; 00567 } 00568 00569 // This function may get "field >= 1", and need it to return ""field" >= 1" 00570 $lbound = ($first_word_only === TRUE) ? '' : '|\s|\('; 00571 00572 $item = preg_replace('/(^'.$lbound.')([\w\d\-\_]+?)(\s|\)|$)/iS', '$1"$2"$3', $item); 00573 } 00574 else 00575 { 00576 return "\"{$item}\""; 00577 } 00578 00579 $exceptions = array('AS', '/', '-', '%', '+', '*', 'OR', 'IS'); 00580 00581 foreach ($exceptions as $exception) 00582 { 00583 00584 if (stristr($item, " \"{$exception}\" ") !== FALSE) 00585 { 00586 $item = preg_replace('/ "('.preg_quote($exception).')" /i', ' $1 ', $item); 00587 } 00588 } 00589 return $item; 00590 }

| CI_DB_oci8_driver::_set_stmt_id | ( | $ | sql | ) |
Generate a statement ID.
private
| string | an SQL query |
Definition at line 156 of file oci8_driver.php.
References _prep_query().
Referenced by _execute(), and stored_procedure().
00157 { 00158 if ( ! is_resource($this->stmt_id)) 00159 { 00160 $this->stmt_id = ociparse($this->conn_id, $this->_prep_query($sql)); 00161 } 00162 }


| CI_DB_oci8_driver::_truncate | ( | $ | table | ) |
Truncate statement.
Generates a platform-specific truncate string from the supplied data If the database does not support the truncate() command This function maps to "DELETE FROM table"
public
| string | the table name |
Definition at line 678 of file oci8_driver.php.
| CI_DB_oci8_driver::_update | ( | $ | table, | |
| $ | values, | |||
| $ | where, | |||
| $ | orderby = array(), |
|||
| $ | limit = FALSE | |||
| ) |
Update statement.
Generates a platform-specific update string from the supplied data
public
| string | the table name | |
| array | the update data | |
| array | the where clause | |
| array | the orderby clause | |
| array | the limit clause |
Definition at line 647 of file oci8_driver.php.
00648 { 00649 foreach($values as $key => $val) 00650 { 00651 $valstr[] = $key." = ".$val; 00652 } 00653 00654 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; 00655 00656 $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; 00657 00658 $sql = "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr); 00659 $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; 00660 $sql .= $orderby.$limit; 00661 00662 return $sql; 00663 }
| CI_DB_oci8_driver::_version | ( | ) |
| CI_DB_oci8_driver::affected_rows | ( | ) |
| CI_DB_oci8_driver::count_all | ( | $ | table = '' |
) |
"Count All" query
Generates a platform-specific query string that counts all records in the specified database
public
| string |
Definition at line 411 of file oci8_driver.php.
References _protect_identifiers().
00412 { 00413 if ($table == '') 00414 return '0'; 00415 00416 $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows'). " FROM " . $this->_protect_identifiers($this->dbprefix.$table)); 00417 00418 if ($query == FALSE) 00419 { 00420 return 0; 00421 } 00422 00423 $row = $query->row(); 00424 return $row->NUMROWS; 00425 }

| CI_DB_oci8_driver::db_connect | ( | ) |
Non-persistent database connection.
private called by the base class
Definition at line 71 of file oci8_driver.php.
| CI_DB_oci8_driver::db_pconnect | ( | ) |
Persistent database connection.
private called by the base class
Definition at line 84 of file oci8_driver.php.
| CI_DB_oci8_driver::db_select | ( | ) |
Select the database.
private called by the base class
Definition at line 97 of file oci8_driver.php.
| CI_DB_oci8_driver::db_set_charset | ( | $ | charset, | |
| $ | collation | |||
| ) |
Set client character set.
public
| string | ||
| string |
Definition at line 112 of file oci8_driver.php.
| CI_DB_oci8_driver::escape_str | ( | $ | str | ) |
Escape String.
public
| string |
Definition at line 367 of file oci8_driver.php.
| CI_DB_oci8_driver::get_cursor | ( | ) |
getCursor.
Returns a cursor from the datbase
public
Definition at line 188 of file oci8_driver.php.
| CI_DB_oci8_driver::insert_id | ( | ) |
Insert ID.
public
Definition at line 393 of file oci8_driver.php.
00394 { 00395 // not supported in oracle 00396 return $this->display_error('db_unsupported_function'); 00397 }
| CI_DB_oci8_driver::stored_procedure | ( | $ | package, | |
| $ | procedure, | |||
| $ | params | |||
| ) |
Stored Procedure.
Executes a stored procedure
public
| package | package stored procedure is in | |
| procedure | stored procedure to execute | |
| params | array of parameters |
KEY OPTIONAL NOTES name no the name of the parameter should be in :<param_name> format value no the value of the parameter. If this is an OUT or IN OUT parameter, this should be a reference to a variable type yes the type of the parameter length yes the max size of the parameter
Definition at line 214 of file oci8_driver.php.
References _bind_params(), _set_stmt_id(), and log_message().
00215 { 00216 if ($package == '' OR $procedure == '' OR ! is_array($params)) 00217 { 00218 if ($this->db_debug) 00219 { 00220 log_message('error', 'Invalid query: '.$package.'.'.$procedure); 00221 return $this->display_error('db_invalid_query'); 00222 } 00223 return FALSE; 00224 } 00225 00226 // build the query string 00227 $sql = "begin $package.$procedure("; 00228 00229 $have_cursor = FALSE; 00230 foreach($params as $param) 00231 { 00232 $sql .= $param['name'] . ","; 00233 00234 if (array_key_exists('type', $param) && ($param['type'] == OCI_B_CURSOR)) 00235 { 00236 $have_cursor = TRUE; 00237 } 00238 } 00239 $sql = trim($sql, ",") . "); end;"; 00240 00241 $this->stmt_id = FALSE; 00242 $this->_set_stmt_id($sql); 00243 $this->_bind_params($params); 00244 $this->query($sql, FALSE, $have_cursor); 00245 }

| CI_DB_oci8_driver::trans_begin | ( | $ | test_mode = FALSE |
) |
Begin Transaction.
public
Definition at line 284 of file oci8_driver.php.
00285 { 00286 if ( ! $this->trans_enabled) 00287 { 00288 return TRUE; 00289 } 00290 00291 // When transactions are nested we only begin/commit/rollback the outermost ones 00292 if ($this->_trans_depth > 0) 00293 { 00294 return TRUE; 00295 } 00296 00297 // Reset the transaction failure flag. 00298 // If the $test_mode flag is set to TRUE transactions will be rolled back 00299 // even if the queries produce a successful result. 00300 $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; 00301 00302 $this->_commit = OCI_DEFAULT; 00303 return TRUE; 00304 }
| CI_DB_oci8_driver::trans_commit | ( | ) |
Commit Transaction.
public
Definition at line 314 of file oci8_driver.php.
00315 { 00316 if ( ! $this->trans_enabled) 00317 { 00318 return TRUE; 00319 } 00320 00321 // When transactions are nested we only begin/commit/rollback the outermost ones 00322 if ($this->_trans_depth > 0) 00323 { 00324 return TRUE; 00325 } 00326 00327 $ret = OCIcommit($this->conn_id); 00328 $this->_commit = OCI_COMMIT_ON_SUCCESS; 00329 return $ret; 00330 }
| CI_DB_oci8_driver::trans_rollback | ( | ) |
Rollback Transaction.
public
Definition at line 340 of file oci8_driver.php.
00341 { 00342 if ( ! $this->trans_enabled) 00343 { 00344 return TRUE; 00345 } 00346 00347 // When transactions are nested we only begin/commit/rollback the outermost ones 00348 if ($this->_trans_depth > 0) 00349 { 00350 return TRUE; 00351 } 00352 00353 $ret = OCIrollback($this->conn_id); 00354 $this->_commit = OCI_COMMIT_ON_SUCCESS; 00355 return $ret; 00356 }
| CI_DB_oci8_driver::$_commit = OCI_COMMIT_ON_SUCCESS |
Definition at line 55 of file oci8_driver.php.
| CI_DB_oci8_driver::$_count_string = "SELECT COUNT(1) AS " |
The syntax to count rows is slightly different across different database engines, so this string appears in each driver and is used for the count_all() and count_all_results() functions.
Definition at line 51 of file oci8_driver.php.
| CI_DB_oci8_driver::$_random_keyword = ' ASC' |
Definition at line 52 of file oci8_driver.php.
| CI_DB_oci8_driver::$curs_id |
Definition at line 59 of file oci8_driver.php.
| CI_DB_oci8_driver::$limit_used |
Definition at line 63 of file oci8_driver.php.
| CI_DB_oci8_driver::$stmt_id |
Definition at line 58 of file oci8_driver.php.