DB
[ class tree: DB ] [ index: DB ] [ all elements ]

Class: DB_oci8

Source Location: /DB-1.7.2/DB/oci8.php

Class Overview

PEAR
   |
   --DB_common
      |
      --DB_oci8

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


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 1997-2005 The PHP Group

Variables

Methods


Inherited Variables

Inherited Methods

Class: DB_common

DB_common::DB_common()
This constructor calls $this->PEAR('DB_Error')
DB_common::affectedRows()
Determines the number of rows affected by a data maniuplation query
DB_common::autoCommit()
Enables or disables automatic commits
DB_common::autoExecute()
Automaticaly generates an insert or update query and call prepare() and execute() with it
DB_common::autoPrepare()
Automaticaly generates an insert or update query and pass it to prepare()
DB_common::buildManipSQL()
Produces an SQL query string for autoPrepare()
DB_common::commit()
Commits the current transaction
DB_common::createSequence()
Creates a new sequence
DB_common::dropSequence()
Deletes a sequence
DB_common::errorCode()
Maps native error codes to DB's portable ones
DB_common::errorMessage()
Maps a DB error code to a textual message
DB_common::errorNative()
Gets the DBMS' native error code produced by the last query
DB_common::escapeSimple()
Escapes a string according to the current DBMS's standards
DB_common::execute()
Executes a DB statement prepared with prepare()
DB_common::executeEmulateQuery()
Emulates executing prepared statements if the DBMS not support them
DB_common::executeMultiple()
Performs several execute() calls on the same statement handle
DB_common::freePrepared()
Frees the internal resources associated with a prepared query
DB_common::getAll()
Fetches all of the rows from a query result
DB_common::getAssoc()
Fetches an entire query result and returns it as an associative array using the first column as the key
DB_common::getCol()
Fetches a single column from a query result and returns it as an indexed array
DB_common::getListOf()
Lists internal database information
DB_common::getOne()
Fetches the first column of the first row from a query result
DB_common::getOption()
Returns the value of an option
DB_common::getRow()
Fetches the first row of data returned from a query result
DB_common::getSequenceName()
Generates the name used inside the database for a sequence
DB_common::getSpecialQuery()
Obtains the query string needed for listing a given type of objects
DB_common::getTables()
Lists the tables in the current database
DB_common::limitQuery()
Generates and executes a LIMIT query
DB_common::modifyLimitQuery()
Adds LIMIT clauses to a query string according to current DBMS standards
DB_common::modifyQuery()
Changes a query string for various DBMS specific reasons
DB_common::nextId()
Returns the next free id in a sequence
DB_common::numRows()
Determines the number of rows in a query result
DB_common::prepare()
Prepares a query for multiple execution with execute()
DB_common::provides()
Tells whether the present driver supports a given feature
DB_common::query()
Sends a query to the database server
DB_common::quote()
DEPRECATED: Quotes a string so it can be safely used in a query
DB_common::quoteIdentifier()
Quotes a string so it can be safely used as a table or column name
DB_common::quoteSmart()
Formats input so it can be safely used in a query
DB_common::quoteString()
DEPRECATED: Quotes a string so it can be safely used within string delimiters in a query
DB_common::raiseError()
Communicates an error and invoke error callbacks, etc
DB_common::rollback()
Reverts the current transaction
DB_common::setFetchMode()
Sets the fetch mode that should be used by default for query results
DB_common::setOption()
Sets run-time configuration options for PEAR DB
DB_common::tableInfo()
Returns information about a table or a result set
DB_common::toString()
DEPRECATED: String conversion method
DB_common::_convertNullArrayValuesToEmpty()
Converts all null values in an array to empty strings
DB_common::_rtrimArrayValues()
Right-trims all strings in an array
DB_common::__sleep()
Automatically indicates which properties should be saved when PHP's serialize() function is called
DB_common::__toString()
Automatic string conversion for PHP 5
DB_common::__wakeup()
Automatically reconnects to the database when PHP's unserialize() function is called

Class Details

[line 53]
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.



[ Top ]


Class Variables

$connection =

[line 121]

The raw database connection created by PHP

Type:   resource


[ Top ]

$dbsyntax =  'oci8'

[line 67]

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

Type:   string


[ Top ]

$dsn = array()

[line 127]

The DSN information for connecting to a database

Type:   array


[ Top ]

$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,
    )

[line 96]

A mapping of native error codes to DB error codes

Type:   array


[ Top ]

$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


Type:   array


[ Top ]

$last_stmt =

[line 154]

The result or statement handle from the most recently executed query

Type:   resource


[ Top ]

$phptype =  'oci8'

[line 61]

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

Type:   string


[ Top ]



Method Detail

DB_oci8 (Constructor)   [line 172]

void DB_oci8( )

This constructor calls $this->DB_common()

[ Top ]

affectedRows   [line 730]

int affectedRows( )

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.

Overrides DB_common::affectedRows() (Determines the number of rows affected by a data maniuplation query)
[ Top ]

autoCommit   [line 680]

int autoCommit( [bool $onoff = false])

Enables or disables automatic commits
  • Return: DB_OK on success. A DB_Error object if the driver doesn't support auto-committing transactions.

Overrides DB_common::autoCommit() (Enables or disables automatic commits)

Parameters:

bool   $onoff   —  true turns it on, false turns it off

[ Top ]

commit   [line 694]

int commit( )

Commits the current transaction
  • Return: DB_OK on success. A DB_Error object on failure.

Overrides DB_common::commit() (Commits the current transaction)
[ Top ]

connect   [line 208]

int connect( array $dsn, [bool $persistent = false])

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.

Parameters:

array   $dsn   —  the data source name
bool   $persistent   —  should the connection be persistent?

[ Top ]

createSequence   [line 882]

int createSequence( string $seq_name)

Creates a new sequence

Overrides DB_common::createSequence() (Creates a new sequence)

Parameters:

string   $seq_name   —  name of the new sequence

[ Top ]

disconnect   [line 271]

bool disconnect( )

Disconnects from the database server
  • Return: TRUE on success, FALSE on failure

[ Top ]

dropSequence   [line 901]

int dropSequence( string $seq_name)

Deletes a sequence

Overrides DB_common::dropSequence() (Deletes a sequence)

Parameters:

string   $seq_name   —  name of the sequence to be deleted

[ Top ]

errorNative   [line 945]

int errorNative( )

Gets the DBMS' native error code produced by the last query
  • Return: the DBMS' error code. FALSE if the code could not be determined

Overrides DB_common::errorNative() (Gets the DBMS' native error code produced by the last query)
[ Top ]

execute   [line 611]

mixed &execute( resource $stmt, [mixed $data = array()])

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()

Overrides DB_common::execute() (Executes a DB statement prepared with prepare())

Parameters:

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.

[ Top ]

fetchInto   [line 365]

mixed fetchInto( resource $result, &$arr, int $fetchmode, [int $rownum = null], array $arr)

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()

Parameters:

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   — 

[ Top ]

freePrepared   [line 425]

bool freePrepared( resource $stmt, [bool $free_resource = true])

Frees the internal resources associated with a prepared query

Overrides DB_common::freePrepared() (Frees the internal resources associated with a prepared query)

Parameters:

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.

[ Top ]

freeResult   [line 408]

bool freeResult( resource $result)

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.


Parameters:

resource   $result   —  PHP's query result resource

[ Top ]

getSpecialQuery   [line 1086]

string getSpecialQuery( string $type)

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

Overrides DB_common::getSpecialQuery() (Obtains the query string needed for listing a given type of objects)

Parameters:

string   $type   —  the kind of objects you want to retrieve

[ Top ]

modifyLimitQuery   [line 784]

string modifyLimitQuery( string $query, int $from, int $count, [mixed $params = array()])

Adds LIMIT clauses to a query string according to current DBMS standards
  • Return: the query string with LIMIT clauses added
  • Access: protected

Overrides DB_common::modifyLimitQuery() (Adds LIMIT clauses to a query string according to current DBMS standards)

Parameters:

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.

[ Top ]

modifyQuery   [line 756]

string modifyQuery( string $query)

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

Overrides DB_common::modifyQuery() (Changes a query string for various DBMS specific reasons)

Parameters:

string   $query   —  the query string to modify

[ Top ]

nextId   [line 846]

int nextId( string $seq_name, [boolean $ondemand = true])

Returns the next free id in a sequence

Overrides DB_common::nextId() (Returns the next free id in a sequence)

Parameters:

string   $seq_name   —  name of the sequence
boolean   $ondemand   —  when true, the seqence is automatically created if it does not exist

[ Top ]

nextResult   [line 337]

true nextResult( a $result)

Move the internal oracle result pointer to the next available result
  • Return: if a result is available otherwise return false
  • Access: public

Parameters:

a   $result   —  valid oci8 result resource

[ Top ]

numCols   [line 506]

int numCols( resource $result)

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.


Parameters:

resource   $result   —  PHP's query result resource

[ Top ]

numRows   [line 461]

int numRows( resource $result)

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.


Overrides DB_common::numRows() (Determines the number of rows in a query result)

Parameters:

resource   $result   —  PHP's query result resource

[ Top ]

oci8RaiseError   [line 922]

object the oci8RaiseError( [int $errno = null])

Produces a DB_Error object regarding the current problem

Parameters:

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.

[ Top ]

prepare   [line 545]

mixed prepare( string $query)

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'"


Overrides DB_common::prepare() (Prepares a query for multiple execution with execute())

Parameters:

string   $query   —  the query to be prepared

[ Top ]

rollback   [line 711]

int rollback( )

Reverts the current transaction
  • Return: DB_OK on success. A DB_Error object on failure.

Overrides DB_common::rollback() (Reverts the current transaction)
[ Top ]

simpleQuery   [line 298]

mixed simpleQuery( string $query)

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

Parameters:

string   $query   —  the SQL query string

[ Top ]

tableInfo   [line 981]

array tableInfo( object|string $result, [int $mode = null])

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()

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

Parameters:

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

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:28:04 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.