

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_identifiers ($item) | |
| Escape the SQL 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 | |
| $dbdriver = 'oci8' | |
| $_escape_char = '"' | |
| $_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 261 of file oci8_driver.php.
Referenced by stored_procedure().
00262 { 00263 if ( ! is_array($params) OR ! is_resource($this->stmt_id)) 00264 { 00265 return; 00266 } 00267 00268 foreach ($params as $param) 00269 { 00270 foreach (array('name', 'value', 'type', 'length') as $val) 00271 { 00272 if ( ! isset($param[$val])) 00273 { 00274 $param[$val] = ''; 00275 } 00276 } 00277 00278 ocibindbyname($this->stmt_id, $param['name'], $param['value'], $param['length'], $param['type']); 00279 } 00280 }

| CI_DB_oci8_driver::_close | ( | $ | conn_id | ) |
Close DB Connection.
public
| resource |
Definition at line 715 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 656 of file oci8_driver.php.
00657 { 00658 $conditions = ''; 00659 00660 if (count($where) > 0 OR count($like) > 0) 00661 { 00662 $conditions = "\nWHERE "; 00663 $conditions .= implode("\n", $this->ar_where); 00664 00665 if (count($where) > 0 && count($like) > 0) 00666 { 00667 $conditions .= " AND "; 00668 } 00669 $conditions .= implode("\n", $like); 00670 } 00671 00672 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; 00673 00674 return "DELETE FROM ".$table.$conditions.$limit; 00675 }
| CI_DB_oci8_driver::_error_message | ( | ) |
| CI_DB_oci8_driver::_error_number | ( | ) |
| CI_DB_oci8_driver::_escape_identifiers | ( | $ | item | ) |
Escape the SQL Identifiers.
This function escapes column and table names
private
| string |
Definition at line 530 of file oci8_driver.php.
00531 { 00532 if ($this->_escape_char == '') 00533 { 00534 return $item; 00535 } 00536 00537 if (strpos($item, '.') !== FALSE) 00538 { 00539 $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char; 00540 } 00541 else 00542 { 00543 $str = $this->_escape_char.$item.$this->_escape_char; 00544 } 00545 00546 // remove duplicates if the user already included the escape 00547 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); 00548 }
| CI_DB_oci8_driver::_execute | ( | $ | sql | ) |
Execute the query.
private called by the base class
| string | an SQL query |
Definition at line 145 of file oci8_driver.php.
References _set_stmt_id().
00146 { 00147 // oracle must parse the query before it is run. All of the actions with 00148 // the query are based on the statement id returned by ociparse 00149 $this->stmt_id = FALSE; 00150 $this->_set_stmt_id($sql); 00151 ocisetprefetch($this->stmt_id, 1000); 00152 return @ociexecute($this->stmt_id, $this->_commit); 00153 }

| 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 486 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 562 of file oci8_driver.php.
00563 { 00564 if ( ! is_array($tables)) 00565 { 00566 $tables = array($tables); 00567 } 00568 00569 return implode(', ', $tables); 00570 }
| 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 585 of file oci8_driver.php.
00586 { 00587 return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")"; 00588 }
| 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 690 of file oci8_driver.php.
00691 { 00692 $limit = $offset + $limit; 00693 $newsql = "SELECT * FROM (select inner_query.*, rownum rnum FROM ($sql) inner_query WHERE rownum < $limit)"; 00694 00695 if ($offset != 0) 00696 { 00697 $newsql .= " WHERE rnum >= $offset"; 00698 } 00699 00700 // remember that we used limits 00701 $this->limit_used = TRUE; 00702 00703 return $newsql; 00704 }
| 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 470 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 447 of file oci8_driver.php.
00448 { 00449 $sql = "SELECT TABLE_NAME FROM ALL_TABLES"; 00450 00451 if ($prefix_limit !== FALSE AND $this->dbprefix != '') 00452 { 00453 $sql .= " WHERE TABLE_NAME LIKE '".$this->dbprefix."%'"; 00454 } 00455 00456 return $sql; 00457 }
| 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 181 of file oci8_driver.php.
Referenced by _set_stmt_id().

| CI_DB_oci8_driver::_set_stmt_id | ( | $ | sql | ) |
Generate a statement ID.
private
| string | an SQL query |
Definition at line 162 of file oci8_driver.php.
References _prep_query().
Referenced by _execute(), and stored_procedure().
00163 { 00164 if ( ! is_resource($this->stmt_id)) 00165 { 00166 $this->stmt_id = ociparse($this->conn_id, $this->_prep_query($sql)); 00167 } 00168 }


| 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 638 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 605 of file oci8_driver.php.
00606 { 00607 foreach($values as $key => $val) 00608 { 00609 $valstr[] = $key." = ".$val; 00610 } 00611 00612 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; 00613 00614 $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):''; 00615 00616 $sql = "UPDATE ".$table." SET ".implode(', ', $valstr); 00617 00618 $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : ''; 00619 00620 $sql .= $orderby.$limit; 00621 00622 return $sql; 00623 }
| 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 420 of file oci8_driver.php.
00421 { 00422 if ($table == '') 00423 return '0'; 00424 00425 $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows'). " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE)); 00426 00427 if ($query == FALSE) 00428 { 00429 return 0; 00430 } 00431 00432 $row = $query->row(); 00433 return $row->NUMROWS; 00434 }
| CI_DB_oci8_driver::db_connect | ( | ) |
Non-persistent database connection.
private called by the base class
Definition at line 76 of file oci8_driver.php.
| CI_DB_oci8_driver::db_pconnect | ( | ) |
Persistent database connection.
private called by the base class
Definition at line 89 of file oci8_driver.php.
| CI_DB_oci8_driver::db_select | ( | ) |
Select the database.
private called by the base class
Definition at line 102 of file oci8_driver.php.
| CI_DB_oci8_driver::db_set_charset | ( | $ | charset, | |
| $ | collation | |||
| ) |
Set client character set.
public
| string | ||
| string |
Definition at line 117 of file oci8_driver.php.
| CI_DB_oci8_driver::escape_str | ( | $ | str | ) |
Escape String.
public
| string |
Definition at line 373 of file oci8_driver.php.
References $CI, and get_instance().
00374 { 00375 // Access the CI object 00376 $CI =& get_instance(); 00377 00378 return $CI->_remove_invisible_characters($str); 00379 }

| CI_DB_oci8_driver::get_cursor | ( | ) |
getCursor.
Returns a cursor from the datbase
public
Definition at line 194 of file oci8_driver.php.
| CI_DB_oci8_driver::insert_id | ( | ) |
Insert ID.
public
Definition at line 402 of file oci8_driver.php.
00403 { 00404 // not supported in oracle 00405 return $this->display_error('db_unsupported_function'); 00406 }
| 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 220 of file oci8_driver.php.
References _bind_params(), _set_stmt_id(), and log_message().
00221 { 00222 if ($package == '' OR $procedure == '' OR ! is_array($params)) 00223 { 00224 if ($this->db_debug) 00225 { 00226 log_message('error', 'Invalid query: '.$package.'.'.$procedure); 00227 return $this->display_error('db_invalid_query'); 00228 } 00229 return FALSE; 00230 } 00231 00232 // build the query string 00233 $sql = "begin $package.$procedure("; 00234 00235 $have_cursor = FALSE; 00236 foreach($params as $param) 00237 { 00238 $sql .= $param['name'] . ","; 00239 00240 if (array_key_exists('type', $param) && ($param['type'] == OCI_B_CURSOR)) 00241 { 00242 $have_cursor = TRUE; 00243 } 00244 } 00245 $sql = trim($sql, ",") . "); end;"; 00246 00247 $this->stmt_id = FALSE; 00248 $this->_set_stmt_id($sql); 00249 $this->_bind_params($params); 00250 $this->query($sql, FALSE, $have_cursor); 00251 }

| CI_DB_oci8_driver::trans_begin | ( | $ | test_mode = FALSE |
) |
Begin Transaction.
public
Definition at line 290 of file oci8_driver.php.
00291 { 00292 if ( ! $this->trans_enabled) 00293 { 00294 return TRUE; 00295 } 00296 00297 // When transactions are nested we only begin/commit/rollback the outermost ones 00298 if ($this->_trans_depth > 0) 00299 { 00300 return TRUE; 00301 } 00302 00303 // Reset the transaction failure flag. 00304 // If the $test_mode flag is set to TRUE transactions will be rolled back 00305 // even if the queries produce a successful result. 00306 $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE; 00307 00308 $this->_commit = OCI_DEFAULT; 00309 return TRUE; 00310 }
| CI_DB_oci8_driver::trans_commit | ( | ) |
Commit Transaction.
public
Definition at line 320 of file oci8_driver.php.
00321 { 00322 if ( ! $this->trans_enabled) 00323 { 00324 return TRUE; 00325 } 00326 00327 // When transactions are nested we only begin/commit/rollback the outermost ones 00328 if ($this->_trans_depth > 0) 00329 { 00330 return TRUE; 00331 } 00332 00333 $ret = OCIcommit($this->conn_id); 00334 $this->_commit = OCI_COMMIT_ON_SUCCESS; 00335 return $ret; 00336 }
| CI_DB_oci8_driver::trans_rollback | ( | ) |
Rollback Transaction.
public
Definition at line 346 of file oci8_driver.php.
00347 { 00348 if ( ! $this->trans_enabled) 00349 { 00350 return TRUE; 00351 } 00352 00353 // When transactions are nested we only begin/commit/rollback the outermost ones 00354 if ($this->_trans_depth > 0) 00355 { 00356 return TRUE; 00357 } 00358 00359 $ret = OCIrollback($this->conn_id); 00360 $this->_commit = OCI_COMMIT_ON_SUCCESS; 00361 return $ret; 00362 }
| CI_DB_oci8_driver::$_commit = OCI_COMMIT_ON_SUCCESS |
Definition at line 60 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 56 of file oci8_driver.php.
| CI_DB_oci8_driver::$_escape_char = '"' |
Definition at line 49 of file oci8_driver.php.
| CI_DB_oci8_driver::$_random_keyword = ' ASC' |
Definition at line 57 of file oci8_driver.php.
| CI_DB_oci8_driver::$curs_id |
Definition at line 64 of file oci8_driver.php.
| CI_DB_oci8_driver::$dbdriver = 'oci8' |
Definition at line 46 of file oci8_driver.php.
| CI_DB_oci8_driver::$limit_used |
Definition at line 68 of file oci8_driver.php.
| CI_DB_oci8_driver::$stmt_id |
Definition at line 63 of file oci8_driver.php.