Class DB_oci8

Description

The methods PEAR DB uses to interact with PHP's oci8 extension for interacting with Oracle databases

Definitely works with versions 8 and 9 of Oracle.

These methods overload the ones declared in DB_common.

Be aware... OCIError() only appears to return anything when given a statement, so functions return the generic DB_ERROR instead of more useful errors that have to do with feedback from the database.

Located in /web/lib/external/pear-db/DB/oci8.php (line 53)

PEAR
   |
   --DB_common
      |
      --DB_oci8
Variable Summary
 resource $connection
 string $dbsyntax
 array $dsn
 array $features
 resource $last_stmt
 string $phptype
Method Summary
 void DB_oci8 ()
 int affectedRows ()
 int autoCommit ([bool $onoff = false])
 int commit ()
 int connect (array $dsn, [bool $persistent = false])
 int createSequence (string $seq_name)
 bool disconnect ()
 int dropSequence (string $seq_name)
 int errorNative ()
 mixed &execute (resource $stmt, [mixed $data = array()])
 mixed fetchInto (resource $result,  &$arr, int $fetchmode, [int $rownum = null], array $arr)
 bool freePrepared (resource $stmt, [bool $free_resource = true])
 bool freeResult (resource $result)
 string getSpecialQuery (string $type)
 string modifyLimitQuery (string $query, int $from, int $count, [mixed $params = array()])
 string modifyQuery (string $query)
 int nextId (string $seq_name, [boolean $ondemand = true])
 true nextResult (a $result)
 int numCols (resource $result)
 int numRows (resource $result)
 object the oci8RaiseError ([int $errno = null])
 mixed prepare (string $query)
 string quoteFloat (float $float)
 int rollback ()
 mixed simpleQuery (string $query)
 array tableInfo (object|string $result, [int $mode = null])
Variables
resource $connection (line 122)

The raw database connection created by PHP

string $dbsyntax = 'oci8' (line 67)

The database syntax variant to be used (db2, access, etc.), if any

array $dsn = array() (line 128)

The DSN information for connecting to a database

array $errorcode_map = array(
1 => DB_ERROR_CONSTRAINT,
900 => DB_ERROR_SYNTAX,
904 => DB_ERROR_NOSUCHFIELD,
913 => DB_ERROR_VALUE_COUNT_ON_ROW,
921 => DB_ERROR_SYNTAX,
923 => DB_ERROR_SYNTAX,
942 => DB_ERROR_NOSUCHTABLE,
955 => DB_ERROR_ALREADY_EXISTS,
1400 => DB_ERROR_CONSTRAINT_NOT_NULL,
1401 => DB_ERROR_INVALID,
1407 => DB_ERROR_CONSTRAINT_NOT_NULL,
1418 => DB_ERROR_NOT_FOUND,
1476 => DB_ERROR_DIVZERO,
1722 => DB_ERROR_INVALID_NUMBER,
2289 => DB_ERROR_NOSUCHTABLE,
2291 => DB_ERROR_CONSTRAINT,
2292 => DB_ERROR_CONSTRAINT,
2449 => DB_ERROR_CONSTRAINT,
12899 => DB_ERROR_INVALID,
)
(line 96)

A mapping of native error codes to DB error codes

array $features = array(
'limit' => 'alter',
'new_link' => '5.0.0',
'numrows' => 'subquery',
'pconnect' => true,
'prepare' => true,
'ssl' => false,
'transactions' => true,
)
(line 82)

The capabilities of this DB implementation

The 'new_link' element contains the PHP version that first provided new_link support for this DBMS. Contains false if it's unsupported.

Meaning of the 'limit' element:

  • 'emulate' = emulate with fetch row by number
  • 'alter' = alter the query
  • false = skip rows

resource $last_stmt (line 155)

The result or statement handle from the most recently executed query

string $phptype = 'oci8' (line 61)

The DB driver type (mysql, oci8, odbc, etc.)

Inherited Variables

Inherited from DB_common

DB_common::$fetchmode
DB_common::$fetchmode_object_class
DB_common::$last_parameters
DB_common::$last_query
DB_common::$options
DB_common::$prepared_queries
DB_common::$prepare_tokens
DB_common::$prepare_types
DB_common::$was_connected
DB_common::$_last_query_manip
DB_common::$_next_query_manip
Methods
Constructor DB_oci8 (line 180)

This constructor calls $this->DB_common()

void DB_oci8 ()
affectedRows (line 759)

Determines the number of rows affected by a data maniuplation query

  1. is returned for queries that don't manipulate data.

  • return: the number of rows. A DB_Error object on failure.
int affectedRows ()

Redefinition of:
DB_common::affectedRows()
Determines the number of rows affected by a data maniuplation query
autoCommit (line 709)

Enables or disables automatic commits

  • return: DB_OK on success. A DB_Error object if the driver doesn't support auto-committing transactions.
int autoCommit ([bool $onoff = false])
  • bool $onoff: true turns it on, false turns it off

Redefinition of:
DB_common::autoCommit()
Enables or disables automatic commits
commit (line 723)

Commits the current transaction

  • return: DB_OK on success. A DB_Error object on failure.
int commit ()

Redefinition of:
DB_common::commit()
Commits the current transaction
connect (line 216)

Connect to the database server, log in and open the database

Don't call this method directly. Use DB::connect() instead.

If PHP is at version 5.0.0 or greater:

  • Generally, oci_connect() or oci_pconnect() are used.
  • But if the new_link DSN option is set to true, oci_new_connect() is used.
When using PHP version 4.x, OCILogon() or OCIPLogon() are used.

PEAR DB's oci8 driver supports the following extra DSN options:

  • charset The character set to be used on the connection. Only used if PHP is at version 5.0.0 or greater and the Oracle server is at 9.2 or greater. Available since PEAR DB 1.7.0.
  • new_link If set to true, causes subsequent calls to connect() to return a new connection link instead of the existing one. WARNING: this is not portable to other DBMS's. Available since PEAR DB 1.7.0.

  • return: DB_OK on success. A DB_Error object on failure.
int connect (array $dsn, [bool $persistent = false])
  • array $dsn: the data source name
  • bool $persistent: should the connection be persistent?
createSequence (line 911)

Creates a new sequence

int createSequence (string $seq_name)
  • string $seq_name: name of the new sequence

Redefinition of:
DB_common::createSequence()
Creates a new sequence
disconnect (line 290)

Disconnects from the database server

  • return: TRUE on success, FALSE on failure
bool disconnect ()
dropSequence (line 930)

Deletes a sequence

int dropSequence (string $seq_name)
  • string $seq_name: name of the sequence to be deleted

Redefinition of:
DB_common::dropSequence()
Deletes a sequence
errorNative (line 974)

Gets the DBMS' native error code produced by the last query

  • return: the DBMS' error code. FALSE if the code could not be determined
int errorNative ()

Redefinition of:
DB_common::errorNative()
Gets the DBMS' native error code produced by the last query
execute (line 629)

Executes a DB statement prepared with prepare().

To determine how many rows of a result set get buffered using ocisetprefetch(), see the "result_buffering" option in setOptions(). This option was added in Release 1.7.0.

  • return: returns an oic8 result resource for successful SELECT queries, DB_OK for other successful queries. A DB error object is returned on failure.
  • see: DB_oci8::prepare()
mixed &execute (resource $stmt, [mixed $data = array()])
  • resource $stmt: a DB statement resource returned from prepare()
  • mixed $data: array, string or numeric data to be used in execution of the statement. Quantity of items passed must match quantity of placeholders in query: meaning 1 for non-array items or the quantity of elements in the array.

Redefinition of:
DB_common::execute()
Executes a DB statement prepared with prepare()
fetchInto (line 384)

Places a row from the result set into the given array

Formating of the array and the data therein are configurable. See DB_result::fetchInto() for more information.

This method is not meant to be called directly. Use DB_result::fetchInto() instead. It can't be declared "protected" because DB_result is a separate object.

  • return: DB_OK on success, NULL when the end of a result set is reached or on failure
  • see: DB_result::fetchInto()
mixed fetchInto (resource $result,  &$arr, int $fetchmode, [int $rownum = null], array $arr)
  • resource $result: the query result resource
  • array $arr: the referenced array to put the data in
  • int $fetchmode: how the resulting array should be indexed
  • int $rownum: the row number to fetch (0 = first row)
  • &$arr
freePrepared (line 444)

Frees the internal resources associated with a prepared query

bool freePrepared (resource $stmt, [bool $free_resource = true])
  • resource $stmt: the prepared statement's resource
  • bool $free_resource: should the PHP resource be freed too? Use false if you need to get data from the result set later.

Redefinition of:
DB_common::freePrepared()
Frees the internal resources associated with a prepared query
freeResult (line 427)

Deletes the result set and frees the memory occupied by the result set

This method is not meant to be called directly. Use DB_result::free() instead. It can't be declared "protected" because DB_result is a separate object.

bool freeResult (resource $result)
  • resource $result: PHP's query result resource
getSpecialQuery (line 1115)

Obtains the query string needed for listing a given type of objects

  • return: the SQL query string or null if the driver doesn't support the object type requested
  • see: DB_common::getListOf()
  • access: protected
string getSpecialQuery (string $type)
  • string $type: the kind of objects you want to retrieve

Redefinition of:
DB_common::getSpecialQuery()
Obtains the query string needed for listing a given type of objects
modifyLimitQuery (line 813)

Adds LIMIT clauses to a query string according to current DBMS standards

  • return: the query string with LIMIT clauses added
  • access: protected
string modifyLimitQuery (string $query, int $from, int $count, [mixed $params = array()])
  • string $query: the query to modify
  • int $from: the row to start to fetching (0 = the first row)
  • int $count: the numbers of rows to fetch
  • mixed $params: array, string or numeric data to be used in execution of the statement. Quantity of items passed must match quantity of placeholders in query: meaning 1 placeholder for non-array parameters or 1 placeholder per array element.

Redefinition of:
DB_common::modifyLimitQuery()
Adds LIMIT clauses to a query string according to current DBMS standards
modifyQuery (line 785)

Changes a query string for various DBMS specific reasons

"SELECT 2+2" must be "SELECT 2+2 FROM dual" in Oracle.

  • return: the modified query string
  • access: protected
string modifyQuery (string $query)
  • string $query: the query string to modify

Redefinition of:
DB_common::modifyQuery()
Changes a query string for various DBMS specific reasons
nextId (line 875)

Returns the next free id in a sequence

int nextId (string $seq_name, [boolean $ondemand = true])
  • string $seq_name: name of the sequence
  • boolean $ondemand: when true, the seqence is automatically created if it does not exist

Redefinition of:
DB_common::nextId()
Returns the next free id in a sequence
nextResult (line 356)

Move the internal oracle result pointer to the next available result

  • return: if a result is available otherwise return false
  • access: public
true nextResult (a $result)
  • a $result: valid oci8 result resource
numCols (line 523)

Gets the number of columns in a result set

This method is not meant to be called directly. Use DB_result::numCols() instead. It can't be declared "protected" because DB_result is a separate object.

int numCols (resource $result)
  • resource $result: PHP's query result resource
numRows (line 480)

Gets the number of rows in a result set

Only works if the DB_PORTABILITY_NUMROWS portability option is turned on.

This method is not meant to be called directly. Use DB_result::numRows() instead. It can't be declared "protected" because DB_result is a separate object.

int numRows (resource $result)
  • resource $result: PHP's query result resource

Redefinition of:
DB_common::numRows()
Determines the number of rows in a query result
oci8RaiseError (line 951)

Produces a DB_Error object regarding the current problem

object the oci8RaiseError ([int $errno = null])
  • int $errno: if the error is being manually raised pass a DB_ERROR* constant here. If this isn't passed the error information gathered from the DBMS.
prepare (line 562)

Prepares a query for multiple execution with execute().

With oci8, this is emulated.

prepare() requires a generic query as string like

  1.     INSERT INTO numbers VALUES (???)
. The ? characters are placeholders.

Three types of placeholders can be used:

  • ? a quoted scalar value, i.e. strings, integers
  • ! value is inserted 'as is'
  • & requires a file name. The file's contents get inserted into the query (i.e. saving binary data in a db)
Use backslashes to escape placeholder characters if you don't want them to be interpreted as placeholders. Example:
  1.     "UPDATE foo SET col=? WHERE col='over \& under'"

mixed prepare (string $query)
  • string $query: the query to be prepared

Redefinition of:
DB_common::prepare()
Prepares a query for multiple execution with execute()
quoteFloat (line 1141)

Formats a float value for use within a query in a locale-independent manner.

string quoteFloat (float $float)
  • float $float: the float value to be quoted.

Redefinition of:
DB_common::quoteFloat()
Formats a float value for use within a query in a locale-independent manner.
rollback (line 740)

Reverts the current transaction

  • return: DB_OK on success. A DB_Error object on failure.
int rollback ()

Redefinition of:
DB_common::rollback()
Reverts the current transaction
simpleQuery (line 317)

Sends a query to the database server

To determine how many rows of a result set get buffered using ocisetprefetch(), see the "result_buffering" option in setOptions(). This option was added in Release 1.7.0.

  • return: + a PHP result resrouce for successful SELECT queries
    • the DB_OK constant for other successful queries
    • a DB_Error object on failure
mixed simpleQuery (string $query)
  • string $query: the SQL query string
tableInfo (line 1010)

Returns information about a table or a result set

NOTE: only supports 'table' and 'flags' if $result is a table name.

NOTE: flags won't contain index information.

  • return: an associative array with the information requested. A DB_Error object on failure.
  • see: DB_common::tableInfo()
array tableInfo (object|string $result, [int $mode = null])
  • object|string $result: DB_result object from a query or a string containing the name of a table. While this also accepts a query result resource identifier, this behavior is deprecated.
  • int $mode: a valid tableInfo mode

Redefinition of:
DB_common::tableInfo()
Returns information about a table or a result set

Inherited Methods

Inherited From DB_common

 DB_common::DB_common()
 DB_common::affectedRows()
 DB_common::autoCommit()
 DB_common::autoExecute()
 DB_common::autoPrepare()
 DB_common::buildManipSQL()
 DB_common::commit()
 DB_common::createSequence()
 DB_common::dropSequence()
 DB_common::errorCode()
 DB_common::errorMessage()
 DB_common::errorNative()
 DB_common::escapeSimple()
 DB_common::execute()
 DB_common::executeEmulateQuery()
 DB_common::executeMultiple()
 DB_common::freePrepared()
 DB_common::getAll()
 DB_common::getAssoc()
 DB_common::getCol()
 DB_common::getListOf()
 DB_common::getOne()
 DB_common::getOption()
 DB_common::getRow()
 DB_common::getSequenceName()
 DB_common::getSpecialQuery()
 DB_common::getTables()
 DB_common::limitQuery()
 DB_common::modifyLimitQuery()
 DB_common::modifyQuery()
 DB_common::nextId()
 DB_common::nextQueryIsManip()
 DB_common::numRows()
 DB_common::prepare()
 DB_common::provides()
 DB_common::query()
 DB_common::quote()
 DB_common::quoteBoolean()
 DB_common::quoteFloat()
 DB_common::quoteIdentifier()
 DB_common::quoteSmart()
 DB_common::quoteString()
 DB_common::raiseError()
 DB_common::rollback()
 DB_common::setFetchMode()
 DB_common::setOption()
 DB_common::tableInfo()
 DB_common::toString()
 DB_common::_checkManip()
 DB_common::_convertNullArrayValuesToEmpty()
 DB_common::_rtrimArrayValues()
 DB_common::__sleep()
 DB_common::__toString()
 DB_common::__wakeup()

Inherited From PEAR

 PEAR::PEAR()
 PEAR::delExpect()
 PEAR::expectError()
 PEAR::getStaticProperty()
 PEAR::isError()
 PEAR::loadExtension()
 PEAR::popErrorHandling()
 PEAR::popExpect()
 PEAR::pushErrorHandling()
 PEAR::raiseError()
 PEAR::registerShutdownFunc()
 PEAR::setErrorHandling()
 PEAR::staticPopErrorHandling()
 PEAR::staticPushErrorHandling()
 PEAR::throwError()
 PEAR::_PEAR()

Documentation generated on Wed, 09 Feb 2011 09:02:29 +0700 by phpDocumentor 1.4.2