ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
MDB2_Driver_oci8 Class Reference
+ Inheritance diagram for MDB2_Driver_oci8:
+ Collaboration diagram for MDB2_Driver_oci8:

Public Member Functions

 __construct ()
 Constructor.
 errorInfo ($error=null)
 This method is used to collect information about an error.
 beginTransaction ($savepoint=null)
 Start a transaction or set a savepoint.
 commit ($savepoint=null)
 Commit the database changes done during a transaction that is in progress or release a savepoint.
 rollback ($savepoint=null)
 Cancel any database changes done during a transaction or since a specific savepoint that is in progress.
 setTransactionIsolation ($isolation)
 Set the transacton isolation level.
 _doConnect ($username, $password, $persistent=false)
 do the grunt work of the connect
 connect ()
 Connect to the database.
 disconnect ($force=true)
 Log out and disconnect from the database.
standaloneExec ($query)
 execute a query as database administrator
standaloneQuery ($query, $types=null, $is_manip=false)
 execute a query as DBA
 _modifyQuery ($query, $is_manip, $limit, $offset)
 Changes a query string for various DBMS specific reasons.
_doQuery ($query, $is_manip=false, $connection=null, $database_name=null)
 Execute a query.
 _affectedRows ($connection, $result=null)
 Returns the number of rows affected.
 getServerVersion ($native=false)
 return version information about the server
prepare ($query, $types=null, $result_types=null, $lobs=array())
 Prepares a query for multiple execution with execute().
 nextID ($seq_name, $ondemand=true)
 Returns the next free id of a sequence.
 lastInsertID ($table=null, $field=null)
 Returns the autoincrement ID if supported or $id or fetches the current ID in a sequence called: $table.
 currId ($seq_name)
 Returns the current id of a sequence.
- Public Member Functions inherited from MDB2_Driver_Common
 MDB2_Driver_Common ()
 PHP 4 Constructor.
 __destruct ()
 Destructor.
 free ()
 Free the internal references so that the instance can be destroyed.
 __toString ()
 String conversation.
raiseError ($code=null, $mode=null, $options=null, $userinfo=null, $method=null)
 This method is used to communicate an error and invoke error callbacks etc.
 resetWarnings ()
 reset the warning array
 getWarnings ()
 Get all warnings in reverse order.
 setFetchMode ($fetchmode, $object_class= 'stdClass')
 Sets which fetch mode should be used by default on queries on this connection.
 setOption ($option, $value)
 set the option for the db class
 getOption ($option)
 Returns the value of an option.
 debug ($message, $scope= '', $context=array())
 set a debug message
 getDebugOutput ()
 output debug info
 escape ($text, $escape_wildcards=false)
 Quotes a string so it can be safely used in a query.
 escapePattern ($text)
 Quotes pattern (% and _) characters in a string)
 quoteIdentifier ($str, $check_option=false)
 Quote a string so it can be safely used as a table or column name.
 getAsKeyword ()
 Gets the string to alias column.
 getConnection ()
 Returns a native connection.
 _fixResultArrayValues (&$row, $mode)
 Do all necessary conversions on result arrays to fix DBMS quirks.
loadModule ($module, $property=null, $phptype_specific=null)
 loads a module
 __call ($method, $params)
 Calls a module method using the __call magic method.
 inTransaction ($ignore_nested=false)
 If a transaction is currently open.
 setTransactionIsolation ($isolation, $options=array())
 Set the transacton isolation level.
 beginNestedTransaction ()
 Start a nested transaction.
 completeNestedTransaction ($force_rollback=false)
 Finish a nested transaction by rolling back if an error occured or committing otherwise.
 failNestedTransaction ($error=null, $immediately=false)
 Force setting nested transaction to failed.
 getNestedTransactionError ()
 The first error that occured since the transaction start.
 setCharset ($charset, $connection=null)
 Set the charset on the current connection.
 setDatabase ($name)
 Select a different database.
 getDatabase ()
 Get the current database.
 setDSN ($dsn)
 set the DSN
 getDSN ($type= 'string', $hidepw=false)
 return the DSN as a string
exec ($query)
 Execute a manipulation query to the database and return the number of affected rows.
query ($query, $types=null, $result_class=true, $result_wrap_class=false)
 Send a query to the database and return any results.
_wrapResult ($result, $types=array(), $result_class=true, $result_wrap_class=false, $limit=null, $offset=null)
 wrap a result set into the correct class
 setLimit ($limit, $offset=null)
 set the range of the next query
 subSelect ($query, $type=false)
 simple subselect emulation: leaves the query untouched for all RDBMS that support subselects
 replace ($table, $fields)
 Execute a SQL REPLACE query.
 _skipDelimitedStrings ($query, $position, $p_position)
 Utility method, used by prepare() to avoid replacing placeholders within delimited strings.
 quote ($value, $type=null, $quote=true, $escape_wildcards=false)
 Convert a text value into a DBMS specific format that is suitable to compose query statements.
 getDeclaration ($type, $name, $field)
 Obtain DBMS specific SQL code portion needed to declare of the given type.
 compareDefinition ($current, $previous)
 Obtain an array of changes that may need to applied.
 supports ($feature)
 Tell whether a DB implementation or its backend extension supports a given feature.
 getSequenceName ($sqn)
 adds sequence name formatting to a sequence name
 getIndexName ($idx)
 adds index name formatting to a index name
 currID ($seq_name)
 Returns the current id of a sequence.
 queryOne ($query, $type=null, $colnum=0)
 Execute the specified query, fetch the value from the first column of the first row of the result set and then frees the result set.
 queryRow ($query, $types=null, $fetchmode=MDB2_FETCHMODE_DEFAULT)
 Execute the specified query, fetch the values from the first row of the result set into an array and then frees the result set.
 queryCol ($query, $type=null, $colnum=0)
 Execute the specified query, fetch the value from the first column of each row of the result set into an array and then frees the result set.
 queryAll ($query, $types=null, $fetchmode=MDB2_FETCHMODE_DEFAULT, $rekey=false, $force_array=false, $group=false)
 Execute the specified query, fetch all the rows of the result set into a two dimensional array and then frees the result set.
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor.
 _PEAR ()
 Destructor (the emulated type of...).
getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them.
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes.
 isError ($data, $code=null)
 Tell whether a value is a PEAR error.
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled.
 expectError ($code= '*')
 This method is used to tell which errors you expect to get.
 popExpect ()
 This method pops one element off the expected error codes stack.
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available.
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack.
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied.
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options.
 staticPushErrorHandling ($mode, $options=null)
 staticPopErrorHandling ()
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack.
 popErrorHandling ()
 Pop the last error handler used.
 loadExtension ($ext)
 OS independant PHP extension load.

Data Fields

 $string_quoting = array('start' => "'", 'end' => "'", 'escape' => "'", 'escape_pattern' => '@')
 $identifier_quoting = array('start' => '"', 'end' => '"', 'escape' => '"')
 $uncommitedqueries = 0
- Data Fields inherited from MDB2_Driver_Common
 $db_index = 0
 $dsn = array()
 $connected_dsn = array()
 $connection = 0
 $opened_persistent
 $database_name = ''
 $connected_database_name = ''
 $connected_server_info = ''
 $supported
 $options
 $string_quoting = array('start' => "'", 'end' => "'", 'escape' => false, 'escape_pattern' => false)
 $identifier_quoting = array('start' => '"', 'end' => '"', 'escape' => '"')
 $sql_comments
 $wildcards = array('%', '_')
 $as_keyword = ' AS '
 $warnings = array()
 $debug_output = ''
 $in_transaction = false
 $nested_transaction_counter = null
 $has_transaction_error = false
 $offset = 0
 $limit = 0
 $phptype
 $dbsyntax
 $last_query
 $fetchmode = MDB2_FETCHMODE_ORDERED
 $modules = array()
 $destructor_registered = true
- Data Fields inherited from PEAR
 $_debug = false
 $_default_error_mode = null
 $_default_error_options = null
 $_default_error_handler = ''
 $_error_class = 'PEAR_Error'
 $_expected_errors = array()

Detailed Description

Definition at line 55 of file oci8.php.

Constructor & Destructor Documentation

MDB2_Driver_oci8::__construct ( )

Constructor.

Reimplemented from MDB2_Driver_Common.

Definition at line 69 of file oci8.php.

{
$this->phptype = 'oci8';
$this->dbsyntax = 'oci8';
$this->supported['sequences'] = true;
$this->supported['indexes'] = true;
$this->supported['summary_functions'] = true;
$this->supported['order_by_text'] = true;
$this->supported['current_id'] = true;
$this->supported['affected_rows'] = true;
$this->supported['transactions'] = true;
$this->supported['savepoints'] = true;
$this->supported['limit_queries'] = true;
$this->supported['LOBs'] = true;
$this->supported['replace'] = 'emulated';
$this->supported['sub_selects'] = true;
$this->supported['auto_increment'] = false; // implementation is broken
$this->supported['primary_key'] = true;
$this->supported['result_introspection'] = true;
$this->supported['prepared_statements'] = true;
$this->supported['identifier_quoting'] = true;
$this->supported['pattern_escaping'] = true;
$this->supported['new_link'] = true;
$this->options['DBA_username'] = false;
$this->options['DBA_password'] = false;
$this->options['database_name_prefix'] = false;
$this->options['emulate_database'] = true;
$this->options['default_tablespace'] = false;
$this->options['default_text_field_length'] = 2000;
$this->options['result_prefetching'] = false;
}

Member Function Documentation

MDB2_Driver_oci8::_affectedRows (   $connection,
  $result = null 
)

Returns the number of rows affected.

Parameters
resource$result
resource$connection
Returns
mixed MDB2 Error Object or the number of rows affected private

Reimplemented from MDB2_Driver_Common.

Definition at line 684 of file oci8.php.

References MDB2_Driver_Common\$connection, MDB2_Driver_Common\getConnection(), and PEAR\isError().

Referenced by standaloneExec(), and standaloneQuery().

{
if (is_null($connection)) {
return $connection;
}
}
return @OCIRowCount($result);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

MDB2_Driver_oci8::_doConnect (   $username,
  $password,
  $persistent = false 
)

do the grunt work of the connect

Returns
connection on success or MDB2 Error Object on failure protected

Definition at line 319 of file oci8.php.

References MDB2_Driver_Common\$connection, MDB2_Driver_Common\$database_name, $error, $query, _doQuery(), disconnect(), PEAR\isError(), PEAR\loadExtension(), MDB2_ERROR_CONNECT_FAILED, MDB2_ERROR_NOT_FOUND, MDB2_Driver_Common\raiseError(), and MDB2_Driver_Common\setCharset().

Referenced by connect(), standaloneExec(), and standaloneQuery().

{
if (!PEAR::loadExtension($this->phptype)) {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
'extension '.$this->phptype.' is not compiled into PHP', __FUNCTION__);
}
$sid = '';
if (!empty($this->dsn['service']) && $this->dsn['hostspec']) {
//oci8://username:password@foo.example.com[:port]/?service=service
// service name is given, it is assumed that hostspec is really a
// hostname, we try to construct an oracle connection string from this
$port = $this->dsn['port'] ? $this->dsn['port'] : 1521;
$sid = sprintf("(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)
(HOST=%s) (PORT=%s)))
(CONNECT_DATA=(SERVICE_NAME=%s)))",
$this->dsn['hostspec'],
$port,
$this->dsn['service']
);
} elseif ($this->dsn['hostspec']) {
// we are given something like 'oci8://username:password@foo/'
// we have hostspec but not a service name, now we assume that
// hostspec is a tnsname defined in tnsnames.ora
$sid = $this->dsn['hostspec'];
} else {
// oci://username:password@
// if everything fails, we have to rely on environment variables
// not before a check to 'emulate_database'
if (!$this->options['emulate_database'] && $this->database_name) {
} elseif (getenv('ORACLE_SID')) {
$sid = getenv('ORACLE_SID');
} elseif ($sid = getenv('TWO_TASK')) {
$sid = getenv('TWO_TASK');
} else {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
'not a valid connection string or environment variable [ORACLE_SID|TWO_TASK] not set',
__FUNCTION__);
}
}
if (function_exists('oci_connect')) {
if (isset($this->dsn['new_link'])
&& ($this->dsn['new_link'] == 'true' || $this->dsn['new_link'] === true)
) {
$connect_function = 'oci_new_connect';
} else {
$connect_function = $persistent ? 'oci_pconnect' : 'oci_connect';
}
$charset = empty($this->dsn['charset']) ? null : $this->dsn['charset'];
$connection = @$connect_function($username, $password, $sid, $charset);
$error = @OCIError();
if (isset($error['code']) && $error['code'] == 12541) {
// Couldn't find TNS listener. Try direct connection.
$connection = @$connect_function($username, $password, null, $charset);
}
} else {
$connect_function = $persistent ? 'OCIPLogon' : 'OCILogon';
$connection = @$connect_function($username, $password, $sid);
if (!empty($this->dsn['charset'])) {
$result = $this->setCharset($this->dsn['charset'], $connection);
if (PEAR::isError($result)) {
return $result;
}
}
}
if (!$connection) {
return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null,
'unable to establish a connection', __FUNCTION__);
}
if (empty($this->dsn['disable_iso_date'])) {
$query = "ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'";
$err =& $this->_doQuery($query, true, $connection);
if (PEAR::isError($err)) {
$this->disconnect(false);
return $err;
}
}
$query = "ALTER SESSION SET NLS_NUMERIC_CHARACTERS='. '";
$err =& $this->_doQuery($query, true, $connection);
if (PEAR::isError($err)) {
$this->disconnect(false);
return $err;
}
return $connection;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

& MDB2_Driver_oci8::_doQuery (   $query,
  $is_manip = false,
  $connection = null,
  $database_name = null 
)

Execute a query.

Parameters
string$queryquery
boolean$is_manipif the query is a manipulation query
resource$connection
string$database_name
Returns
result or error object protected

Reimplemented from MDB2_Driver_Common.

Definition at line 627 of file oci8.php.

References MDB2_Driver_Common\$connection, $query, MDB2_Driver_Common\debug(), MDB2_Driver_Common\getConnection(), MDB2_Driver_Common\getOption(), PEAR\isError(), and MDB2_Driver_Common\raiseError().

Referenced by _doConnect(), beginTransaction(), rollback(), setTransactionIsolation(), standaloneExec(), and standaloneQuery().

{
$this->last_query = $query;
$result = $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'pre'));
if ($result) {
if (PEAR::isError($result)) {
return $result;
}
$query = $result;
}
if ($this->getOption('disable_query')) {
if ($is_manip) {
return 0;
}
return null;
}
if (is_null($connection)) {
return $connection;
}
}
$result = @OCIParse($connection, $query);
if (!$result) {
$err = $this->raiseError(null, null, null,
'Could not create statement', __FUNCTION__);
return $err;
}
$mode = $this->in_transaction ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS;
if (!@OCIExecute($result, $mode)) {
$err =& $this->raiseError($result, null, null,
'Could not execute statement', __FUNCTION__);
return $err;
}
if (is_numeric($this->options['result_prefetching'])) {
@ocisetprefetch($result, $this->options['result_prefetching']);
}
$this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'post', 'result' => $result));
return $result;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

MDB2_Driver_oci8::_modifyQuery (   $query,
  $is_manip,
  $limit,
  $offset 
)

Changes a query string for various DBMS specific reasons.

Parameters
string$queryquery to modify
boolean$is_manipif it is a DML query
integer$limitlimit the number of rows
integer$offsetstart reading from given offset
Returns
string modified query protected

Reimplemented from MDB2_Driver_Common.

Definition at line 595 of file oci8.php.

References MDB2_Driver_Common\$limit, MDB2_Driver_Common\$offset, and $query.

Referenced by prepare(), standaloneExec(), and standaloneQuery().

{
if (preg_match('/^\s*SELECT/i', $query)) {
if (!preg_match('/\sFROM\s/i', $query)) {
$query.= " FROM dual";
}
if ($limit > 0) {
// taken from http://svn.ez.no/svn/ezcomponents/packages/Database
$max = $offset + $limit;
if ($offset > 0) {
$min = $offset + 1;
$query = "SELECT * FROM (SELECT a.*, ROWNUM mdb2rn FROM ($query) a WHERE ROWNUM <= $max) WHERE mdb2rn >= $min";
} else {
$query = "SELECT a.* FROM ($query) a WHERE ROWNUM <= $max";
}
}
}
return $query;
}

+ Here is the caller graph for this function:

MDB2_Driver_oci8::beginTransaction (   $savepoint = null)

Start a transaction or set a savepoint.

Parameters
stringname of a savepoint to set
Returns
mixed MDB2_OK on success, a MDB2 error on failure

public

Reimplemented from MDB2_Driver_Common.

Definition at line 171 of file oci8.php.

References $query, $uncommitedqueries, _doQuery(), MDB2_Driver_Common\debug(), MDB2_ERROR_INVALID, MDB2_OK, and MDB2_Driver_Common\raiseError().

{
$this->debug('Starting transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint));
if (!is_null($savepoint)) {
if (!$this->in_transaction) {
return $this->raiseError(MDB2_ERROR_INVALID, null, null,
'savepoint cannot be released when changes are auto committed', __FUNCTION__);
}
$query = 'SAVEPOINT '.$savepoint;
return $this->_doQuery($query, true);
} elseif ($this->in_transaction) {
return MDB2_OK; //nothing to do
}
if (!$this->destructor_registered && $this->opened_persistent) {
$this->destructor_registered = true;
register_shutdown_function('MDB2_closeOpenTransactions');
}
$this->in_transaction = true;
return MDB2_OK;
}

+ Here is the call graph for this function:

MDB2_Driver_oci8::commit (   $savepoint = null)

Commit the database changes done during a transaction that is in progress or release a savepoint.

This function may only be called when auto-committing is disabled, otherwise it will fail. Therefore, a new transaction is implicitly started after committing the pending changes.

Parameters
stringname of a savepoint to release
Returns
mixed MDB2_OK on success, a MDB2 error on failure

public

Reimplemented from MDB2_Driver_Common.

Definition at line 207 of file oci8.php.

References MDB2_Driver_Common\$connection, MDB2_Driver_Common\debug(), MDB2_Driver_Common\getConnection(), PEAR\isError(), MDB2_ERROR_INVALID, MDB2_OK, and MDB2_Driver_Common\raiseError().

{
$this->debug('Committing transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint));
if (!$this->in_transaction) {
return $this->raiseError(MDB2_ERROR_INVALID, null, null,
'commit/release savepoint cannot be done changes are auto committed', __FUNCTION__);
}
if (!is_null($savepoint)) {
return MDB2_OK;
}
if ($this->uncommitedqueries) {
return $connection;
}
if (!@OCICommit($connection)) {
return $this->raiseError(null, null, null,
'Unable to commit transaction', __FUNCTION__);
}
$this->uncommitedqueries = 0;
}
$this->in_transaction = false;
return MDB2_OK;
}

+ Here is the call graph for this function:

MDB2_Driver_oci8::connect ( )

Connect to the database.

Returns
MDB2_OK on success, MDB2 Error Object on failure public

Reimplemented from MDB2_Driver_Common.

Definition at line 423 of file oci8.php.

References MDB2_Driver_Common\$connection, MDB2_Driver_Common\$database_name, MDB2_Driver_Common\$dsn, MDB2_Driver_Common\$phptype, _doConnect(), disconnect(), getServerVersion(), PEAR\isError(), and MDB2_OK.

{
if ($this->database_name && $this->options['emulate_database']) {
$this->dsn['username'] = $this->options['database_name_prefix'].$this->database_name;
}
if (is_resource($this->connection)) {
if (count(array_diff($this->connected_dsn, $this->dsn)) == 0
&& $this->connected_database_name == $this->database_name
&& $this->opened_persistent == $this->options['persistent']
) {
return MDB2_OK;
}
$this->disconnect(false);
}
$this->dsn['username'],
$this->dsn['password'],
$this->options['persistent']
);
return $connection;
}
$this->connection = $connection;
$this->connected_dsn = $this->dsn;
$this->connected_database_name = $this->database_name;
$this->opened_persistent = $this->options['persistent'];
$this->dbsyntax = $this->dsn['dbsyntax'] ? $this->dsn['dbsyntax'] : $this->phptype;
$this->as_keyword = ' ';
$server_info = $this->getServerVersion();
if (is_array($server_info)) {
if ($server_info['major'] >= '10') {
$this->as_keyword = ' AS ';
}
}
return MDB2_OK;
}

+ Here is the call graph for this function:

MDB2_Driver_oci8::currId (   $seq_name)

Returns the current id of a sequence.

Parameters
string$seq_namename of the sequence
Returns
mixed MDB2_Error or id public

Definition at line 951 of file oci8.php.

References $query, MDB2_Driver_Common\getSequenceName(), and MDB2_Driver_Common\queryOne().

{
$sequence_name = $this->getSequenceName($seq_name);
$query = 'SELECT (last_number-1) FROM user_sequences';
$query.= ' WHERE sequence_name='.$this->quote($sequence_name, 'text');
$query.= ' OR sequence_name='.$this->quote(strtoupper($sequence_name), 'text');
return $this->queryOne($query, 'integer');
}

+ Here is the call graph for this function:

MDB2_Driver_oci8::disconnect (   $force = true)

Log out and disconnect from the database.

Parameters
boolean$forceif the disconnect should be forced even if the connection is opened persistently
Returns
mixed true on success, false if not connected and error object on error public

Reimplemented from MDB2_Driver_Common.

Definition at line 474 of file oci8.php.

References MDB2_Driver_Common\$connected_database_name, MDB2_Driver_Common\$connected_dsn, MDB2_Driver_Common\$database_name, MDB2_Driver_Common\$dsn, MDB2_Driver_Common\$opened_persistent, and rollback().

Referenced by _doConnect(), and connect().

{
if (is_resource($this->connection)) {
if ($this->in_transaction) {
$persistent = $this->options['persistent'];
$this->dsn = $this->connected_dsn;
$this->database_name = $this->connected_database_name;
$this->options['persistent'] = $this->opened_persistent;
$this->rollback();
$this->dsn = $dsn;
$this->database_name = $database_name;
$this->options['persistent'] = $persistent;
}
if (!$this->opened_persistent || $force) {
if (function_exists('oci_close')) {
@oci_close($this->connection);
} else {
@OCILogOff($this->connection);
}
}
$this->uncommitedqueries = 0;
}
return parent::disconnect($force);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

MDB2_Driver_oci8::errorInfo (   $error = null)

This method is used to collect information about an error.

Parameters
integer$error
Returns
array public

Reimplemented from MDB2_Driver_Common.

Definition at line 115 of file oci8.php.

References $error, MDB2_ERROR_ALREADY_EXISTS, MDB2_ERROR_CONSTRAINT, MDB2_ERROR_CONSTRAINT_NOT_NULL, MDB2_ERROR_DIVZERO, MDB2_ERROR_INVALID, MDB2_ERROR_INVALID_NUMBER, MDB2_ERROR_NOSUCHFIELD, MDB2_ERROR_NOSUCHTABLE, MDB2_ERROR_NOT_FOUND, MDB2_ERROR_SYNTAX, and MDB2_ERROR_VALUE_COUNT_ON_ROW.

{
if (is_resource($error)) {
$error_data = @OCIError($error);
$error = null;
} elseif ($this->connection) {
$error_data = @OCIError($this->connection);
} else {
$error_data = @OCIError();
}
$native_code = $error_data['code'];
$native_msg = $error_data['message'];
if (is_null($error)) {
static $ecode_map;
if (empty($ecode_map)) {
$ecode_map = array(
911 => MDB2_ERROR_SYNTAX, //invalid character
24344 => MDB2_ERROR_SYNTAX, //success with compilation error
);
}
if (isset($ecode_map[$native_code])) {
$error = $ecode_map[$native_code];
}
}
return array($error, $native_code, $native_msg);
}
MDB2_Driver_oci8::getServerVersion (   $native = false)

return version information about the server

Parameters
bool$nativedetermines if the raw version string should be returned
Returns
mixed array/string with version information or MDB2 error object public

Reimplemented from MDB2_Driver_Common.

Definition at line 705 of file oci8.php.

References MDB2_Driver_Common\$connected_server_info, MDB2_Driver_Common\$connection, MDB2_Driver_Common\getConnection(), PEAR\isError(), MDB2_ERROR_INVALID, and MDB2_Driver_Common\raiseError().

Referenced by connect().

{
return $connection;
}
if ($this->connected_server_info) {
} else {
$server_info = @ociserverversion($connection);
}
if (!$server_info) {
return $this->raiseError(null, null, null,
'Could not get server information', __FUNCTION__);
}
// cache server_info
$this->connected_server_info = $server_info;
if (!$native) {
if (!preg_match('/ (\d+)\.(\d+)\.(\d+)\.([\d\.]+) /', $server_info, $tmp)) {
return $this->raiseError(MDB2_ERROR_INVALID, null, null,
'Could not parse version information:'.$server_info, __FUNCTION__);
}
$server_info = array(
'major' => $tmp[1],
'minor' => $tmp[2],
'patch' => $tmp[3],
'extra' => $tmp[4],
'native' => $server_info,
);
}
return $server_info;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

MDB2_Driver_oci8::lastInsertID (   $table = null,
  $field = null 
)

Returns the autoincrement ID if supported or $id or fetches the current ID in a sequence called: $table.

(empty($field) ? '' : '_'.$field)

Parameters
string$tablename of the table into which a new row was inserted
string$fieldname of the field into which a new row was inserted
Returns
mixed MDB2 Error Object or id public

Reimplemented from MDB2_Driver_Common.

Definition at line 934 of file oci8.php.

References MDB2_Driver_Common\getSequenceName(), MDB2_Driver_Common\queryOne(), and MDB2_Driver_Common\quoteIdentifier().

{
$seq = $table.(empty($field) ? '' : '_'.$field);
$sequence_name = $this->quoteIdentifier($this->getSequenceName($seq), true);
return $this->queryOne("SELECT $sequence_name.currval", 'integer');
}

+ Here is the call graph for this function:

MDB2_Driver_oci8::nextID (   $seq_name,
  $ondemand = true 
)

Returns the next free id of a sequence.

Parameters
string$seq_namename of the sequence
boolean$ondemandwhen true the sequence is automatic created, if it not exists
Returns
mixed MDB2 Error Object or id public

Reimplemented from MDB2_Driver_Common.

Definition at line 902 of file oci8.php.

References $query, PEAR\expectError(), MDB2_Driver_Common\getSequenceName(), PEAR\isError(), MDB2_Driver_Common\loadModule(), MDB2_ERROR_NOSUCHTABLE, PEAR\popExpect(), MDB2_Driver_Common\queryOne(), and MDB2_Driver_Common\quoteIdentifier().

{
$sequence_name = $this->quoteIdentifier($this->getSequenceName($seq_name), true);
$query = "SELECT $sequence_name.nextval FROM DUAL";
$result = $this->queryOne($query, 'integer');
$this->popExpect();
if (PEAR::isError($result)) {
if ($ondemand && $result->getCode() == MDB2_ERROR_NOSUCHTABLE) {
$this->loadModule('Manager', null, true);
$result = $this->manager->createSequence($seq_name);
if (PEAR::isError($result)) {
return $result;
}
return $this->nextId($seq_name, false);
}
}
return $result;
}

+ Here is the call graph for this function:

& MDB2_Driver_oci8::prepare (   $query,
  $types = null,
  $result_types = null,
  $lobs = array() 
)

Prepares a query for multiple execution with execute().

With some database backends, this is emulated. prepare() requires a generic query as string like 'INSERT INTO numbers VALUES(?,?)' or 'INSERT INTO numbers VALUES(:foo,:bar)'. The ? and :[a-zA-Z] and are placeholders which can be set using bindParam() and the query can be send off using the execute() method.

Parameters
string$querythe query to prepare
mixed$typesarray that contains the types of the placeholders
mixed$result_typesarray that contains the types of the columns in the result set or MDB2_PREPARE_RESULT, if set to MDB2_PREPARE_MANIP the query is handled as a manipulation query
mixed$lobskey (field) value (parameter) pair for all lob placeholders
Returns
mixed resource handle for the prepared query on success, a MDB2 error on failure public
See Also
bindParam, execute

Reimplemented from MDB2_Driver_Common.

Definition at line 761 of file oci8.php.

References MDB2_Driver_Common\$connection, MDB2_Driver_Common\$limit, MDB2_Driver_Common\$offset, $query, _modifyQuery(), MDB2_Driver_Common\_skipDelimitedStrings(), MDB2_Driver_Common\debug(), MDB2_Driver_Common\getConnection(), PEAR\isError(), MDB2_ERROR_SYNTAX, MDB2_PREPARE_MANIP, MDB2_Driver_Common\quote(), and MDB2_Driver_Common\raiseError().

{
if ($this->options['emulate_prepared']) {
$obj =& parent::prepare($query, $types, $result_types, $lobs);
return $obj;
}
$is_manip = ($result_types === MDB2_PREPARE_MANIP);
$this->offset = $this->limit = 0;
$result = $this->debug($query, __FUNCTION__, array('is_manip' => $is_manip, 'when' => 'pre'));
if ($result) {
if (PEAR::isError($result)) {
return $result;
}
$query = $result;
}
$query = $this->_modifyQuery($query, $is_manip, $limit, $offset);
$placeholder_type_guess = $placeholder_type = null;
$question = '?';
$colon = ':';
$positions = array();
$position = 0;
$parameter = -1;
while ($position < strlen($query)) {
$q_position = strpos($query, $question, $position);
$c_position = strpos($query, $colon, $position);
if ($q_position && $c_position) {
$p_position = min($q_position, $c_position);
} elseif ($q_position) {
$p_position = $q_position;
} elseif ($c_position) {
$p_position = $c_position;
} else {
break;
}
if (is_null($placeholder_type)) {
$placeholder_type_guess = $query[$p_position];
}
$new_pos = $this->_skipDelimitedStrings($query, $position, $p_position);
if (PEAR::isError($new_pos)) {
return $new_pos;
}
if ($new_pos != $position) {
$position = $new_pos;
continue; //evaluate again starting from the new position
}
if ($query[$position] == $placeholder_type_guess) {
if (is_null($placeholder_type)) {
$placeholder_type = $query[$p_position];
$question = $colon = $placeholder_type;
if (!empty($types) && is_array($types)) {
if ($placeholder_type == ':') {
if (is_int(key($types))) {
$types_tmp = $types;
$types = array();
$count = -1;
}
} else {
$types = array_values($types);
}
}
}
if ($placeholder_type == ':') {
$parameter = preg_replace('/^.{'.($position+1).'}([a-z0-9_]+).*$/si', '\\1', $query);
if ($parameter === '') {
$err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null,
'named parameter with an empty name', __FUNCTION__);
return $err;
}
// use parameter name in type array
if (isset($count) && isset($types_tmp[++$count])) {
$types[$parameter] = $types_tmp[$count];
}
$length = strlen($parameter) + 1;
} else {
++$parameter;
$length = strlen($parameter);
}
if (!in_array($parameter, $positions)) {
$positions[] = $parameter;
}
if (isset($types[$parameter])
&& ($types[$parameter] == 'clob' || $types[$parameter] == 'blob')
) {
if (!isset($lobs[$parameter])) {
$lobs[$parameter] = $parameter;
}
$value = $this->quote(true, $types[$parameter]);
$query = substr_replace($query, $value, $p_position, $length);
$position = $p_position + strlen($value) - 1;
} elseif ($placeholder_type == '?') {
$query = substr_replace($query, ':'.$parameter, $p_position, 1);
$position = $p_position + $length;
} else {
$position = $p_position + 1;
}
} else {
$position = $p_position;
}
}
if (is_array($lobs)) {
$columns = $variables = '';
foreach ($lobs as $parameter => $field) {
$columns.= ($columns ? ', ' : ' RETURNING ').$field;
$variables.= ($variables ? ', ' : ' INTO ').':'.$parameter;
}
$query.= $columns.$variables;
}
return $connection;
}
$statement = @OCIParse($connection, $query);
if (!$statement) {
$err =& $this->raiseError(null, null, null,
'Could not create statement', __FUNCTION__);
return $err;
}
$class_name = 'MDB2_Statement_'.$this->phptype;
$obj =& new $class_name($this, $statement, $positions, $query, $types, $result_types, $is_manip, $limit, $offset);
$this->debug($query, __FUNCTION__, array('is_manip' => $is_manip, 'when' => 'post', 'result' => $obj));
return $obj;
}

+ Here is the call graph for this function:

MDB2_Driver_oci8::rollback (   $savepoint = null)

Cancel any database changes done during a transaction or since a specific savepoint that is in progress.

This function may only be called when auto-committing is disabled, otherwise it will fail. Therefore, a new transaction is implicitly started after canceling the pending changes.

Parameters
stringname of a savepoint to rollback to
Returns
mixed MDB2_OK on success, a MDB2 error on failure

public

Reimplemented from MDB2_Driver_Common.

Definition at line 247 of file oci8.php.

References MDB2_Driver_Common\$connection, $query, _doQuery(), MDB2_Driver_Common\debug(), MDB2_Driver_Common\getConnection(), PEAR\isError(), MDB2_ERROR_INVALID, MDB2_OK, and MDB2_Driver_Common\raiseError().

Referenced by disconnect().

{
$this->debug('Rolling back transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint));
if (!$this->in_transaction) {
return $this->raiseError(MDB2_ERROR_INVALID, null, null,
'rollback cannot be done changes are auto committed', __FUNCTION__);
}
if (!is_null($savepoint)) {
$query = 'ROLLBACK TO SAVEPOINT '.$savepoint;
return $this->_doQuery($query, true);
}
if ($this->uncommitedqueries) {
return $connection;
}
if (!@OCIRollback($connection)) {
return $this->raiseError(null, null, null,
'Unable to rollback transaction', __FUNCTION__);
}
$this->uncommitedqueries = 0;
}
$this->in_transaction = false;
return MDB2_OK;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

MDB2_Driver_oci8::setTransactionIsolation (   $isolation)

Set the transacton isolation level.

Parameters
stringstandard isolation level READ UNCOMMITTED (allows dirty reads) READ COMMITTED (prevents dirty reads) REPEATABLE READ (prevents nonrepeatable reads) SERIALIZABLE (prevents phantom reads)
Returns
mixed MDB2_OK on success, a MDB2 error on failure

public

Since
2.1.1

Definition at line 290 of file oci8.php.

References $query, _doQuery(), MDB2_Driver_Common\debug(), MDB2_ERROR_UNSUPPORTED, and MDB2_Driver_Common\raiseError().

{
$this->debug('Setting transaction isolation level', __FUNCTION__, array('is_manip' => true));
switch ($isolation) {
case 'READ UNCOMMITTED':
$isolation = 'READ COMMITTED';
case 'READ COMMITTED':
case 'REPEATABLE READ':
$isolation = 'SERIALIZABLE';
case 'SERIALIZABLE':
break;
default:
return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'isolation level is not supported: '.$isolation, __FUNCTION__);
}
$query = "ALTER SESSION ISOLATION LEVEL $isolation";
return $this->_doQuery($query, true);
}

+ Here is the call graph for this function:

& MDB2_Driver_oci8::standaloneExec (   $query)

execute a query as database administrator

Parameters
string$querythe SQL query
Returns
mixed MDB2_OK on success, a MDB2 error on failure public

Definition at line 512 of file oci8.php.

References MDB2_Driver_Common\$connection, MDB2_Driver_Common\$limit, MDB2_Driver_Common\$offset, $query, $ret, _affectedRows(), _doConnect(), _doQuery(), _modifyQuery(), and PEAR\isError().

{
$this->options['DBA_username'],
$this->options['DBA_password'],
$this->options['persistent']
);
return $connection;
}
$this->offset = $this->limit = 0;
$query = $this->_modifyQuery($query, false, $limit, $offset);
$result =& $this->_doQuery($query, false, $connection, false);
if (PEAR::isError($result)) {
@OCILogOff($connection);
return $result;
}
$ret = $this->_affectedRows($connection, $result);
@OCILogOff($connection);
return $ret;
}

+ Here is the call graph for this function:

& MDB2_Driver_oci8::standaloneQuery (   $query,
  $types = null,
  $is_manip = false 
)

execute a query as DBA

Parameters
string$querythe SQL query
mixed$typesarray that contains the types of the columns in the result set
boolean$is_manipif the query is a manipulation query
Returns
mixed MDB2_OK on success, a MDB2 error on failure public

Reimplemented from MDB2_Driver_Common.

Definition at line 552 of file oci8.php.

References MDB2_Driver_Common\$connection, MDB2_Driver_Common\$limit, MDB2_Driver_Common\$offset, $query, _affectedRows(), _doConnect(), _doQuery(), _modifyQuery(), MDB2_Driver_Common\_wrapResult(), and PEAR\isError().

{
$this->options['DBA_username'],
$this->options['DBA_password'],
$this->options['persistent']
);
return $connection;
}
$this->offset = $this->limit = 0;
$query = $this->_modifyQuery($query, $is_manip, $limit, $offset);
$result =& $this->_doQuery($query, $is_manip, $connection, false);
@OCILogOff($connection);
if (PEAR::isError($result)) {
return $result;
}
if ($is_manip) {
$affected_rows = $this->_affectedRows($connection, $result);
return $affected_rows;
}
$return =& $this->_wrapResult($result, $types, true, false, $limit, $offset);
return $return;
}

+ Here is the call graph for this function:

Field Documentation

MDB2_Driver_oci8::$identifier_quoting = array('start' => '"', 'end' => '"', 'escape' => '"')

Definition at line 60 of file oci8.php.

MDB2_Driver_oci8::$string_quoting = array('start' => "'", 'end' => "'", 'escape' => "'", 'escape_pattern' => '@')

Definition at line 58 of file oci8.php.

MDB2_Driver_oci8::$uncommitedqueries = 0

Definition at line 62 of file oci8.php.

Referenced by beginTransaction().


The documentation for this class was generated from the following file: