Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

FileDescription

Author: John Lim
Author: George Fourlanos <fou@infomap.gr>
Copyright: 2000-2013 John Lim
Copyright: 2014 Damien Regad, Mark Newnham and the ADOdb community
License: BSD-3-Clause
License: LGPL-2.1-or-later
File Size: 1890 lines (49 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 4 classes

ADODB_oci8:: (42 methods):
  MetaColumns()
  Time()
  _connect()
  ServerInfo()
  _pconnect()
  _nconnect()
  _affectedrows()
  IfNull()
  _insertID()
  DBDate()
  BindDate()
  BindTimeStamp()
  DBTimeStamp()
  RowLock()
  MetaTables()
  MetaIndexes()
  BeginTrans()
  CommitTrans()
  RollbackTrans()
  SelectDB()
  ErrorMsg()
  ErrorNo()
  SQLDate()
  GetRandRow()
  SelectLimit()
  UpdateBlob()
  UpdateBlobFile()
  Execute()
  Prepare()
  releaseStatement()
  ExecuteCursor()
  Bind()
  Param()
  Parameter()
  _query()
  IsConnectionError()
  _close()
  MetaPrimaryKeys()
  metaForeignKeys()
  CharMax()
  TextMax()
  qStr()

Name:: (0 methods):

ADORecordset_oci8:: (13 methods):
  __construct()
  __destruct()
  Init()
  _initrs()
  _FetchField()
  FetchField()
  MoveNext()
  GetArrayLimit()
  Fields()
  _seek()
  _fetch()
  _close()
  MetaType()

ADORecordSet_ext_oci8:: (1 method):
  MoveNext()

Defines 1 function

  oci_lob_desc()

Class: ADODB_oci8  - X-Ref

MetaColumns($table, $normalize=true)   X-Ref
No description

Time()   X-Ref
No description

_connect($argHostname, $argUsername, $argPassword, $argDatabasename=null, $mode=0)   X-Ref
Multiple modes of connection are supported:

a. Local Database
$conn->Connect(false,'scott','tiger');

b. From tnsnames.ora
$conn->Connect($tnsname,'scott','tiger');
$conn->Connect(false,'scott','tiger',$tnsname);

c. Server + service name
$conn->Connect($serveraddress,'scott,'tiger',$service_name);

d. Server + SID
$conn->connectSID = true;
$conn->Connect($serveraddress,'scott,'tiger',$SID);

param: string|false $argHostname DB server hostname or TNS name
param: string $argUsername
param: string $argPassword
param: string $argDatabasename Service name, SID (defaults to null)
param: int $mode Connection mode, defaults to 0
return: bool

ServerInfo()   X-Ref
No description

_pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)   X-Ref
No description

_nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)   X-Ref
No description

_affectedrows()   X-Ref
No description

IfNull( $field, $ifNull )   X-Ref
No description

_insertID($table = '', $column = '')   X-Ref
No description

DBDate($d,$isfld=false)   X-Ref
No description

BindDate($d)   X-Ref
No description

BindTimeStamp($ts)   X-Ref
No description

DBTimeStamp($ts,$isfld=false)   X-Ref
No description

RowLock($tables,$where,$col='1 as adodbignore')   X-Ref
No description

MetaTables($ttype=false,$showSchema=false,$mask=false)   X-Ref
No description

MetaIndexes($table, $primary = FALSE, $owner=false)   X-Ref
No description

BeginTrans()   X-Ref
No description

CommitTrans($ok=true)   X-Ref
No description

RollbackTrans()   X-Ref
No description

SelectDB($dbName)   X-Ref
No description

ErrorMsg()   X-Ref
No description

ErrorNo()   X-Ref
No description

SQLDate($fmt, $col=false)   X-Ref
Format date column in sql string given an input format that understands Y M D


GetRandRow($sql, $arr = false)   X-Ref
No description

SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)   X-Ref
This algorithm makes use of

a. FIRST_ROWS hint
The FIRST_ROWS hint explicitly chooses the approach to optimize response
time, that is, minimum resource usage to return the first row. Results
will be returned as soon as they are identified.

b. Uses rownum tricks to obtain only the required rows from a given offset.
As this uses complicated sql statements, we only use this if $offset >= 100.
This idea by Tomas V V Cox.

This implementation does not appear to work with oracle 8.0.5 or earlier.
Comment out this function then, and the slower SelectLimit() in the base
class will be used.

Note: FIRST_ROWS hinting is only used if $sql is a string; when
processing a prepared statement's handle, no hinting is performed.

UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')   X-Ref
Usage:
Store BLOBs and CLOBs

Example: to store $var in a blob
$conn->Execute('insert into TABLE (id,ablob) values(12,empty_blob())');
$conn->UpdateBlob('TABLE', 'ablob', $varHoldingBlob, 'ID=12', 'BLOB');

$blobtype supports 'BLOB' and 'CLOB', but you need to change to 'empty_clob()'.

to get length of LOB:
select DBMS_LOB.GETLENGTH(ablob) from TABLE

If you are using CURSOR_SHARING = force, it appears this will case a segfault
under oracle 8.1.7.0. Run:
$db->Execute('ALTER SESSION SET CURSOR_SHARING=EXACT');
before UpdateBlob() then...

UpdateBlobFile($table,$column,$val,$where,$blobtype='BLOB')   X-Ref
Usage:  store file pointed to by $val in a blob


Execute($sql,$inputarr=false)   X-Ref
Execute SQL

param: string|array $sql     SQL statement to execute, or possibly an array holding
param: array|false $inputarr holds the input data to bind to.
return: ADORecordSet|false

Prepare($sql,$cursor=false)   X-Ref
No description

releaseStatement(&$stmt)   X-Ref
No description

ExecuteCursor($sql,$cursorName='rs',$params=false)   X-Ref
No description

Bind(&$stmt,&$var,$size=4000,$type=false,$name=false,$isOutput=false)   X-Ref
Bind a variable -- very, very fast for executing repeated statements in oracle.

Better than using
for ($i = 0; $i < $max; $i++) {
$p1 = ?; $p2 = ?; $p3 = ?;
$this->Execute("insert into table (col0, col1, col2) values (:0, :1, :2)", array($p1,$p2,$p3));
}

Usage:
$stmt = $DB->Prepare("insert into table (col0, col1, col2) values (:0, :1, :2)");
$DB->Bind($stmt, $p1);
$DB->Bind($stmt, $p2);
$DB->Bind($stmt, $p3);
for ($i = 0; $i < $max; $i++) {
$p1 = ?; $p2 = ?; $p3 = ?;
$DB->Execute($stmt);
}

Some timings to insert 1000 records, test table has 3 cols, and 1 index.
- Time 0.6081s (1644.60 inserts/sec) with direct oci_parse/oci_execute
- Time 0.6341s (1577.16 inserts/sec) with ADOdb Prepare/Bind/Execute
- Time 1.5533s ( 643.77 inserts/sec) with pure SQL using Execute

Now if PHP only had batch/bulk updating like Java or PL/SQL...

Note that the order of parameters differs from oci_bind_by_name,
because we default the names to :0, :1, :2

Param($name,$type='C')   X-Ref
No description

Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false)   X-Ref
Usage:
$stmt = $db->Prepare('select * from table where id =:myid and group=:group');
$db->Parameter($stmt,$id,'myid');
$db->Parameter($stmt,$group,'group');
$db->Execute($stmt);

param: $stmt Statement returned by {@see Prepare()} or {@see PrepareSP()}.
param: $var PHP variable to bind to
param: $name Name of stored procedure variable name to bind to.
param: bool $isOutput Indicates direction of parameter 0/false=IN  1=OUT  2= IN/OUT. This is ignored in oci8.
param: int $maxLen Holds an maximum length of the variable.
param: mixed $type The data type of $var. Legal values depend on driver.

_query($sql,$inputarr=false)   X-Ref
returns query ID if successful, otherwise false
this version supports:

1. $db->execute('select * from table');

2. $db->prepare('insert into table (a,b,c) values (:0,:1,:2)');
$db->execute($prepared_statement, array(1,2,3));

3. $db->execute('insert into table (a,b,c) values (:a,:b,:c)',array('a'=>1,'b'=>2,'c'=>3));

4. $db->prepare('insert into table (a,b,c) values (:0,:1,:2)');
$db->bind($stmt,1); $db->bind($stmt,2); $db->bind($stmt,3);
$db->execute($stmt);

IsConnectionError($err)   X-Ref
No description

_close()   X-Ref
No description

MetaPrimaryKeys($table, $owner=false,$internalKey=false)   X-Ref
No description

metaForeignKeys($table, $owner = '', $upper = false, $associative = false)   X-Ref
Returns a list of Foreign Keys associated with a specific table.

param: string $table
param: string $owner
param: bool   $upper       discarded
param: bool   $associative discarded
return: string[]|false An array where keys are tables, and values are foreign keys;

CharMax()   X-Ref
No description

TextMax()   X-Ref
No description

qStr($s, $magic_quotes=false)   X-Ref
Correctly quotes a string so that all strings are escaped.
We prefix and append to the string single-quotes.
An example is  $db->qstr("Don't bother");

param: string $s            The string to quote
param: bool   $magic_quotes This param is not used since 5.21.0.
return: string Quoted string to be sent back to database

Class: Name  - X-Ref

Class: ADORecordset_oci8  - X-Ref

__construct($queryID,$mode=false)   X-Ref
No description

__destruct()   X-Ref
Overrides the core destructor method as that causes problems here

return: void

Init()   X-Ref
No description

_initrs()   X-Ref
No description

_FetchField($fieldOffset = -1)   X-Ref
Get column information in the Recordset object.
fetchField() can be used in order to obtain information about fields
in a certain query result. If the field offset isn't specified, the next
field that wasn't yet retrieved by fetchField() is retrieved

return: object containing field information

FetchField($fieldOffset = -1)   X-Ref
No description

MoveNext()   X-Ref
No description

GetArrayLimit($nrows,$offset=-1)   X-Ref
No description

Fields($colname)   X-Ref
No description

_seek($row)   X-Ref
No description

_fetch()   X-Ref
No description

_close()   X-Ref
close() only needs to be called if you are worried about using too much
memory while your script is running. All associated result memory for the
specified result identifier will automatically be freed.


MetaType($t, $len=-1, $fieldobj=false)   X-Ref
not the fastest implementation - quick and dirty - jlim
for best performance, use the actual $rs->MetaType().

param: mixed    $t
param: int        $len        [optional] Length of blobsize
param: bool    $fieldobj    [optional][discarded]
return: str                    The metatype of the field

Class: ADORecordSet_ext_oci8  - X-Ref

MoveNext()   X-Ref
No description

Functions that are not part of a class:

oci_lob_desc($type)   X-Ref
No description