Class DB_oci8

Description

Database independent query interface definition for PHP's Oracle 8 call-interface extension.

Definitely works with versions 8 and 9 of Oracle.

  • author: James L. Pine <jlp@valinux.com>
  • version: $Id: oci8.php,v 1.67 2004/06/24 15:24:56 danielc Exp $

Located in /maintenance/libraries/pear/DB/oci8.php (line 41)

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

Redefinition of:
DB_common::$phptype
DB type (mysql, oci8, odbc etc.)
mixed $prepare_types = array() (line 48)

Redefinition of:
DB_common::$prepare_types
array $_data = array() (line 63)

stores the $data passed to execute() in the oci8 driver

Gets reset to array() when simpleQuery() is run.

Needed in case user wants to call numRows() after prepare/execute was used.

  • access: private

Inherited Variables

Inherited from DB_common

DB_common::$dbh
DB_common::$errorcode_map
DB_common::$features
DB_common::$fetchmode
DB_common::$fetchmode_object_class
DB_common::$last_query
DB_common::$options
DB_common::$prepared_queries
DB_common::$prepare_maxstmt
DB_common::$prepare_tokens
Methods
Constructor DB_oci8 (line 68)
DB_oci8 DB_oci8 ()
affectedRows (line 566)

Gets the number of rows affected by the last query.

if the last query was a select, returns 0.

  • return: of rows affected by the last query or DB_ERROR
number affectedRows ()

Redefinition of:
DB_common::affectedRows()
Returns the affected rows of a query
autoCommit (line 517)

Enable/disable automatic commits

void autoCommit ([$onoff $onoff = false])
  • $onoff $onoff: true/false whether to autocommit

Redefinition of:
DB_common::autoCommit()
enable automatic Commit
commit (line 531)

Commit transactions on the current connection

  • return: or DB_OK
DB_ERROR commit ()

Redefinition of:
DB_common::commit()
starts a Commit
connect (line 110)

Connect to a database and log in as the specified user.

  • return: DB_OK on success, a DB error code on failure
int connect ($dsn $dsninfo, [$persistent $persistent = false])
  • $dsn $dsninfo: the data source name (see DB::parseDSN for syntax)
  • $persistent $persistent: (optional) whether the connection should be persistent
createSequence (line 704)

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

Log out and disconnect from the database.

  • return: true on success, false if not connected.
bool disconnect ()
dropSequence (line 724)

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

Get the native error code of the last error (if any) that occured on the current connection. This does not work, as OCIError does not work unless given a statement. If OCIError does return something, so will this.

  • return: native oci8 error code
int errorNative ()

Redefinition of:
DB_common::errorNative()
Returns an errormessage, provides by the database
execute (line 450)

Executes a DB statement prepared with prepare().

  • return: returns an oci8 result resource for successful SELECT queries, DB_OK for other successful queries. A DB error code is returned on failure.
  • see: DB_oci::prepare()
int &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 228)

Fetch a row and insert the data into an existing array.

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

  • return: DB_OK on success, null when end of result set is reached or on failure
  • access: private
  • see: DB_result::fetchInto()
mixed fetchInto (resource $result, array &$arr, int $fetchmode, [int $rownum = null])
  • resource $result: query result identifier
  • array $arr: (reference) array where data from the row should be placed
  • int $fetchmode: how the resulting array should be indexed
  • int $rownum: the row number to fetch
freePrepared (line 277)

Free the internal resources associated with a prepared query.

  • return: true on success, false if $result is invalid
bool freePrepared ($stmt $stmt)
  • $stmt $stmt: oci8 statement identifier

Redefinition of:
DB_common::freePrepared()
Free the resource used in a prepared query
freeResult (line 265)

Free the internal resources associated with $result.

  • return: true on success, false if $result is invalid
bool freeResult ($result $result)
  • $result $result: oci8 result identifier
getSpecialQuery (line 765)

Returns the query needed to get some backend info

  • return: The SQL query string
string getSpecialQuery (string $type)
  • string $type: What kind of info you want to retrieve

Redefinition of:
DB_common::getSpecialQuery()
Returns the query needed to get some backend info
modifyLimitQuery (line 604)

Emulate the row limit support altering the query

string modifyLimitQuery (string $query, int $from, int $count, [mixed $params = array()])
  • string $query: The query to treat
  • int $from: The row to start to fetch from
  • int $count: The offset

Redefinition of:
DB_common::modifyLimitQuery()
This method is used by backends to alter limited queries
modifyQuery (line 581)
void modifyQuery (mixed $query)

Redefinition of:
DB_common::modifyQuery()
This method is used by backends to alter queries for various reasons
nextId (line 666)

Returns the next free id in a sequence

  • return: the next id number in the sequence. DB_Error if problem.
  • access: public
  • see: DB_common::nextID()
  • internal:
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 202)

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

Get the number of columns in a result set.

  • return: the number of columns per row in $result
int numCols ($result $result)
  • $result $result: oci8 result identifier
numRows (line 291)
void numRows (mixed $result)

Redefinition of:
DB_common::numRows()
Returns the number of rows in a result object
oci8RaiseError (line 743)

Gather information about an error, then use that info to create a DB error object and finally return that object.

object DB oci8RaiseError ([integer $errno = null])
  • integer $errno: PEAR error number (usually a DB constant) if manually raising an error
prepare (line 390)

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

  • return: DB statement resource on success. DB_Error on failure.
mixed prepare (string $query)
  • string $query: query to be prepared

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

Roll back all uncommitted transactions on the current connection.

  • return: or DB_OK
DB_ERROR rollback ()

Redefinition of:
DB_common::rollback()
starts a rollback
simpleQuery (line 167)

Send a query to oracle and return the results as an oci8 resource identifier.

  • return: returns a valid oci8 result for successful SELECT queries, DB_OK for other successful queries. A DB error code is returned on failure.
int simpleQuery ($query $query)
  • $query $query: the SQL query
tableInfo (line 795)

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 or an error object if something is wrong
  • see: DB_common::tableInfo()
  • internal:
  • access: public
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
  • 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::numRows()
 DB_common::prepare()
 DB_common::provides()
 DB_common::query()
 DB_common::quote()
 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::_convertNullArrayValuesToEmpty()
 DB_common::_rtrimArrayValues()

Documentation generated on Fri, 10 Dec 2004 18:25:56 +0000 by phpDocumentor 1.3.0RC3