Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

(no description)

File Size: 5455 lines (147 kb)
Included or required: 4 times
Referenced: 0 times
Includes or requires: 9 files
 lib/adodb/adodb-active-record.inc.php
 lib/adodb/adodb-datadict.inc.php
 lib/adodb/adodb-memcache.lib.inc.php
 lib/adodb/adodb-time.inc.php
 lib/adodb/adodb-csvlib.inc.php
 lib/adodb/toexport.inc.php
 lib/adodb/adodb-lib.inc.php
 lib/adodb/adodb-perf.inc.php
 lib/adodb/adodb-error.inc.php

Defines 9 classes

ADOFieldObject:: (3 methods):
  _adodb_safedate()
  _adodb_safedateq()
  ADODB_TransMonitor()

ADODB_Cache_File:: (8 methods):
  __construct()
  writecache()
  readcache()
  flushall()
  flushcache()
  getdirname()
  createdir()
  _dirFlush()

ADOConnection:: (128 methods):
  __construct()
  setConnectionParameter()
  Version()
  ServerInfo()
  IsConnected()
  _findvers()
  outp()
  Time()
  parseHostNameAndPort()
  Connect()
  _nconnect()
  NConnect()
  PConnect()
  outp_throw()
  _CreateCache()
  SQLDate()
  Prepare()
  PrepareSP()
  Quote()
  q()
  ErrorNative()
  nextId()
  RowLock()
  CommitLock()
  RollbackLock()
  SetFetchMode()
  Query()
  LimitQuery()
  Disconnect()
  Param()
  InParameter()
  OutParameter()
  Parameter()
  IgnoreErrors()
  StartTrans()
  CompleteTrans()
  FailTrans()
  HasFailedTrans()
  Execute()
  _Execute()
  CreateSequence()
  DropSequence()
  GenID()
  Insert_ID()
  PO_Insert_ID()
  Affected_Rows()
  ErrorMsg()
  ErrorNo()
  MetaError()
  MetaErrorMsg()
  MetaPrimaryKeys()
  MetaForeignKeys()
  SelectDB()
  SelectLimit()
  SerializableRS()
  _rs2rs()
  GetAll()
  GetAssoc()
  CacheGetAssoc()
  GetOne()
  GetMedian()
  CacheGetOne()
  GetCol()
  CacheGetCol()
  Transpose()
  OffsetDate()
  GetArray()
  CacheGetAll()
  CacheGetArray()
  GetRandRow()
  GetRow()
  CacheGetRow()
  Replace()
  CacheSelectLimit()
  CacheFlush()
  _gencachename()
  CacheExecute()
  AutoExecute()
  GetUpdateSQL()
  GetInsertSQL()
  UpdateBlob()
  UpdateBlobFile()
  BlobDecode()
  BlobEncode()
  GetCharSet()
  SetCharSet()
  IfNull()
  LogSQL()
  UpdateClob()
  MetaType()
  SetDateLocale()
  GetActiveRecordsClass()
  GetActiveRecords()
  Close()
  BeginTrans()
  SetTransactionMode()
  MetaTransaction()
  CommitTrans()
  RollbackTrans()
  MetaDatabases()
  MetaProcedures()
  MetaTables()
  _findschema()
  MetaColumns()
  MetaIndexes()
  MetaColumnNames()
  Concat()
  DBDate()
  BindDate()
  BindTimeStamp()
  DBTimeStamp()
  UnixDate()
  UnixTimeStamp()
  UserDate()
  UserTimeStamp()
  escape()
  addQ()
  qStr()
  PageExecute()
  CachePageExecute()
  charMax()
  textMax()
  substr()
  month()
  day()
  year()
  resetLastError()
  getChangedErrorMsg()

ADOFetchObj:: (0 methods):

ADODB_Iterator_empty:: (8 methods):
  __construct()
  rewind()
  valid()
  key()
  current()
  next()
  __call()
  hasMore()

ADORecordSet_empty:: (17 methods):
  RowCount()
  RecordCount()
  PO_RecordCount()
  Close()
  FetchRow()
  FieldCount()
  Init()
  getIterator()
  GetAssoc()
  GetArray()
  GetAll()
  GetArrayLimit()
  GetRows()
  GetRowAssoc()
  MaxRecordCount()
  NumRows()
  NumCols()

ADODB_Iterator:: (8 methods):
  __construct()
  rewind()
  valid()
  key()
  current()
  next()
  __call()
  hasMore()

ADORecordSet:: (53 methods):
  __construct()
  __destruct()
  getIterator()
  __toString()
  Init()
  getMenu()
  getMenuGrouped()
  getMenu2()
  getMenu3()
  GetArray()
  GetAll()
  NextRecordSet()
  GetArrayLimit()
  GetRows()
  getAssoc()
  UserTimeStamp()
  UserDate()
  UnixDate()
  UnixTimeStamp()
  Free()
  NumRows()
  NumCols()
  FetchRow()
  FetchInto()
  MoveFirst()
  MoveLast()
  MoveNext()
  Move()
  Fields()
  AssocCaseConvertFunction()
  GetAssocKeys()
  GetRowAssoc()
  Close()
  RecordCount()
  MaxRecordCount()
  RowCount()
  PO_RecordCount()
  CurrentRow()
  AbsolutePosition()
  FieldCount()
  FetchField()
  FieldTypesArray()
  FetchObj()
  FetchObject()
  FetchNextObj()
  FetchNextObject()
  MetaType()
  _updatefields()
  _close()
  AbsolutePage()
  AtFirstPage()
  LastPageNo()
  AtLastPage()

ADORecordSet_array:: (21 methods):
  __construct()
  _transpose()
  InitArray()
  InitArrayFields()
  GetArray()
  _initrs()
  Fields()
  FetchField()
  _seek()
  MoveNext()
  _fetch()
  _close()
  ADOLoadDB()
  ADOLoadCode()
  NewADOConnection()
  ADONewConnection()
  _adodb_getdriver()
  NewPerfMonitor()
  NewDataDictionary()
  adodb_pr()
  adodb_backtrace()

Defines 21 functions

  ADODB_Setup()

Class: ADOFieldObject  - X-Ref

Helper class for FetchFields -- holds info on a column

_adodb_safedate($s)   X-Ref
No description

_adodb_safedateq($s)   X-Ref
No description

ADODB_TransMonitor($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection)   X-Ref
No description

Class: ADODB_Cache_File  - X-Ref

__construct()   X-Ref
No description

writecache($filename, $contents, $debug, $secs2cache)   X-Ref
No description

readcache($filename, &$err, $secs2cache, $rsClass)   X-Ref
No description

flushall($debug=false)   X-Ref
No description

flushcache($f, $debug=false)   X-Ref
No description

getdirname($hash)   X-Ref
No description

createdir($hash, $debug)   X-Ref
No description

_dirFlush($dir, $kill_top_level = false)   X-Ref
Private function to erase all of the files and subdirectories in a directory.

Just specify the directory, and tell it if you want to delete the directory or just clear it out.
Note: $kill_top_level is used internally in the function to flush subdirectories.

Class: ADOConnection  - X-Ref

Connection object. For connecting to databases, and executing queries.

__construct()   X-Ref
Default Constructor.
We define it even though it does not actually do anything. This avoids
getting a PHP Fatal error:  Cannot call constructor if a subclass tries
to call its parent constructor.


setConnectionParameter($parameter,$value)   X-Ref
Adds a parameter to the connection string.

These parameters are added to the connection string when connecting,
if the driver is coded to use it.

param: string    $parameter    The name of the parameter to set
param: string    $value        The value of the parameter
return: null

Version()   X-Ref
ADOdb version.

return: string

ServerInfo()   X-Ref
Get server version info.

return: string[] An array with 2 elements: $arr['string'] is the description string,

IsConnected()   X-Ref
Return true if connected to the database.

return: bool

_findvers($str)   X-Ref
No description

outp($msg,$newline=true)   X-Ref
All error messages go through this bottleneck function.

You can define your own handler by defining the function name in ADODB_OUTP.

param: string $msg     Message to print
param: bool   $newline True to add a newline after printing $msg

Time()   X-Ref
Return the database server's current date and time.

return: int|false

parseHostNameAndPort()   X-Ref
Parses the hostname to extract the port.
Overwrites $this->host and $this->port, only if a port is specified.
The Hostname can be fully or partially qualified,
ie: "db.mydomain.com:5432" or "ldaps://ldap.mydomain.com:636"
Any specified scheme such as ldap:// or ldaps:// is maintained.


Connect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "", $forceNew = false)   X-Ref
Connect to database.

param: string $argHostname     Host to connect to
param: string $argUsername     Userid to login
param: string $argPassword     Associated password
param: string $argDatabaseName Database name
param: bool   $forceNew        Force new connection
return: bool

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

NConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "")   X-Ref
Always force a new connection to database.

Currently this only works with Oracle.

param: string $argHostname     Host to connect to
param: string $argUsername     Userid to login
param: string $argPassword     Associated password
param: string $argDatabaseName Database name
return: bool

PConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "")   X-Ref
Establish persistent connection to database.

param: string $argHostname     Host to connect to
param: string $argUsername     Userid to login
param: string $argPassword     Associated password
param: string $argDatabaseName Database name
return: bool

outp_throw($msg,$src='WARN',$sql='')   X-Ref
No description

_CreateCache()   X-Ref
Create cache class.

Code is backwards-compatible with old memcache implementation.

SQLDate($fmt, $col = '')   X-Ref
Format date column in sql string.

See https://adodb.org/dokuwiki/doku.php?id=v5:reference:connection:sqldate
for documentation on supported formats.

param: string $fmt Format string
param: string $col Date column; use system date if not specified.

Prepare($sql)   X-Ref
Prepare an sql statement and return the statement resource.

For databases that do not support this, we return the $sql. To ensure
compatibility with databases that do not support prepare:

$stmt = $db->Prepare("insert into table (id, name) values (?,?)");
$db->Execute($stmt,array(1,'Jill')) or die('insert failed');
$db->Execute($stmt,array(2,'Joe')) or die('insert failed');

param: string $sql SQL to send to database
return: mixed|false The prepared statement, or the original sql if the

PrepareSP($sql,$param=true)   X-Ref
Prepare a Stored Procedure and return the statement resource.

Some databases, eg. mssql require a different function for preparing
stored procedures. So we cannot use Prepare().

For databases that do not support this, we return the $sql.

param: string $sql   SQL to send to database
param: bool   $param
return: mixed|false The prepared statement, or the original sql if the

Quote($s)   X-Ref
PEAR DB Compat - alias for qStr.

param: $s
return: string

q(&$s)   X-Ref
No description

ErrorNative()   X-Ref
PEAR DB Compat - do not use internally.


nextId($seq_name)   X-Ref
PEAR DB Compat - do not use internally.


RowLock($table,$where,$col='1 as adodbignore')   X-Ref
Lock a row, will escalate and lock the table if row locking not supported
will normally free the lock at the end of the transaction

param: string $table    name of table to lock
param: string $where    where clause to use, eg: "WHERE row=12". If left empty, will escalate to table lock
param: string $col

CommitLock($table)   X-Ref

param: string $table
return: true

RollbackLock($table)   X-Ref

param: string $table
return: true

SetFetchMode($mode)   X-Ref
PEAR DB Compat - do not use internally.

The fetch modes for NUMERIC and ASSOC for PEAR DB and ADODB are identical
for easy porting :-)

param: int $mode The fetchmode ADODB_FETCH_ASSOC or ADODB_FETCH_NUM
return: int Previous fetch mode

Query($sql, $inputarr=false)   X-Ref
PEAR DB Compat - do not use internally.

param: string     $sql
param: array|bool $inputarr
return: ADORecordSet|bool

LimitQuery($sql, $offset, $count, $params=false)   X-Ref
PEAR DB Compat - do not use internally


Disconnect()   X-Ref
PEAR DB Compat - do not use internally


Param($name,$type='C')   X-Ref
Returns a placeholder for query parameters.

e.g. $DB->Param('a') will return
- '?' for most databases
- ':a' for Oracle
- '$1', '$2', etc. for PostgreSQL

param: mixed $name parameter's name.
param: string $type (unused)
return: string query parameter placeholder

InParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false)   X-Ref
No description

OutParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false)   X-Ref
No description

Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false)   X-Ref
No description

IgnoreErrors($saveErrs=false)   X-Ref
No description

StartTrans($errfn = 'ADODB_TransMonitor')   X-Ref
Improved method of initiating a transaction. Used together with CompleteTrans().
Advantages include:

a. StartTrans/CompleteTrans is nestable, unlike BeginTrans/CommitTrans/RollbackTrans.
Only the outermost block is treated as a transaction.<br>
b. CompleteTrans auto-detects SQL errors, and will rollback on errors, commit otherwise.<br>
c. All BeginTrans/CommitTrans/RollbackTrans inside a StartTrans/CompleteTrans block
are disabled, making it backward compatible.

CompleteTrans($autoComplete = true)   X-Ref
No description

FailTrans()   X-Ref
No description

HasFailedTrans()   X-Ref
No description

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

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

_Execute($sql,$inputarr=false)   X-Ref
No description

CreateSequence($seqname='adodbseq',$startID=1)   X-Ref
No description

DropSequence($seqname='adodbseq')   X-Ref
No description

GenID($seqname='adodbseq',$startID=1)   X-Ref
Generates a sequence id and stores it in $this->genID.

GenID is only available if $this->hasGenID = true;

param: string $seqname Name of sequence to use
param: int    $startID If sequence does not exist, start at this ID
return: int Sequence id, 0 if not supported

Insert_ID($table='',$column='')   X-Ref
Returns the last inserted ID.

Not all databases support this feature. Some do not require to specify
table or column name (e.g. MySQL).

param: string $table  Table name, default ''
param: string $column Column name, default ''
return: int The last inserted ID.

PO_Insert_ID($table="", $id="")   X-Ref
Portable Insert ID. Pablo Roca <pabloroca#mvps.org>

param: string $table
param: string $id
return: mixed The last inserted ID. All databases support this, but be

Affected_Rows()   X-Ref

return: # rows affected by UPDATE/DELETE

ErrorMsg()   X-Ref

return: string the last error message

ErrorNo()   X-Ref

return: int the last error number. Normally 0 means no error.

MetaError($err=false)   X-Ref
No description

MetaErrorMsg($errno)   X-Ref
No description

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

returns: an array with the primary key columns in it.

MetaForeignKeys($table, $owner=false, $upper=false)   X-Ref

returns: assoc array where keys are tables, and values are foreign keys

SelectDB($dbName)   X-Ref
Choose a database to connect to. Many databases do not support this.

param: string $dbName the name of the database to select
return: bool

SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)   X-Ref
Select a limited number of rows.

Will select, getting rows from $offset (1-based), for $nrows.
This simulates the MySQL "select * from table limit $offset,$nrows" , and
the PostgreSQL "select * from table limit $nrows offset $offset". Note that
MySQL and PostgreSQL parameter ordering is the opposite of the other.
eg.
SelectLimit('select * from table',3); will return rows 1 to 3 (1-based)
SelectLimit('select * from table',3,2); will return rows 3 to 5 (1-based)

Uses SELECT TOP for Microsoft databases (when $this->hasTop is set)
BUG: Currently SelectLimit fails with $sql with LIMIT or TOP clause already set

param: string     $sql
param: int        $offset     Row to start calculations from (1-based)
param: int        $nrows      Number of rows to get
param: array|bool $inputarr   Array of bind variables
param: int        $secs2cache Private parameter only used by jlim
return: ADORecordSet The recordset ($rs->databaseType == 'array')

SerializableRS(&$rs)   X-Ref
Create serializable recordset. Breaks rs link to connection.

param: ADORecordSet $rs the recordset to serialize
return: ADORecordSet_array|bool the new recordset

_rs2rs(&$rs,$nrows=-1,$offset=-1,$close=true)   X-Ref
Convert a database recordset to an array recordset.

Input recordset's cursor should be at beginning, and old $rs will be closed.

param: ADORecordSet $rs     the recordset to copy
param: int          $nrows  number of rows to retrieve (optional)
param: int          $offset offset by number of rows (optional)
param: bool         $close
return: ADORecordSet_array|ADORecordSet|bool the new recordset

GetAll($sql, $inputarr=false)   X-Ref
No description

GetAssoc($sql, $inputarr = false, $force_array = false, $first2cols = false)   X-Ref
Execute statement and return rows in an array.

The function executes a statement and returns all of the returned rows in
an array, or false if the statement execution fails or if only 1 column
is requested in the SQL statement.
If no records match the provided SQL statement, an empty array is returned.

param: string     $sql         SQL statement
param: array|bool $inputarr    input bind array
param: bool       $force_array
param: bool       $first2cols
return: array|bool

CacheGetAssoc($secs2cache, $sql = false, $inputarr = false,$force_array = false, $first2cols = false)   X-Ref
Search for the results of an executed query in the cache.

param: int $secs2cache
param: string|bool $sql         SQL statement
param: array|bool  $inputarr    input bind array
param: bool        $force_array
param: bool        $first2cols
return: false|array

GetOne($sql, $inputarr=false)   X-Ref
Return first element of first row of sql statement. Recordset is disposed
for you.

param: string        $sql        SQL statement
param: array|bool    $inputarr    input bind array
return: mixed

GetMedian($table, $field,$where = '')   X-Ref
No description

CacheGetOne($secs2cache,$sql=false,$inputarr=false)   X-Ref
No description

GetCol($sql, $inputarr = false, $trim = false)   X-Ref
Executes a statement and returns each row's first column in an array.

param: string     $sql      SQL statement
param: array|bool $inputarr input bind array
param: bool       $trim     enables space trimming of the returned value.
return: array|bool 1D array containning the first row of the query

CacheGetCol($secs, $sql = false, $inputarr = false,$trim=false)   X-Ref
No description

Transpose(&$rs,$addfieldnames=true)   X-Ref
No description

OffsetDate($dayFraction,$date=false)   X-Ref
No description

GetArray($sql,$inputarr=false)   X-Ref
Executes a statement and returns a the entire recordset in an array.

param: string     $sql      SQL statement
param: array|bool $inputarr input bind array
return: array|false

CacheGetAll($secs2cache,$sql=false,$inputarr=false)   X-Ref
No description

CacheGetArray($secs2cache,$sql=false,$inputarr=false)   X-Ref
No description

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

GetRow($sql,$inputarr=false)   X-Ref
Return one row of sql statement. Recordset is disposed for you.
Note that SelectLimit should not be called.

param: string     $sql      SQL statement
param: array|bool $inputarr input bind array
return: array|false Array containing the first row of the query

CacheGetRow($secs2cache,$sql=false,$inputarr=false)   X-Ref

param: int $secs2cache
param: string|false $sql
param: mixed[]|bool $inputarr
return: mixed[]|bool

Replace($table, $fieldArray, $keyCol, $autoQuote=false, $has_autoinc=false)   X-Ref
Insert or replace a single record. Note: this is not the same as MySQL's replace.
ADOdb's Replace() uses update-insert semantics, not insert-delete-duplicates of MySQL.
Also note that no table locking is done currently, so it is possible that the
record be inserted twice by two programs...

$this->Replace('products', array('prodname' =>"'Nails'","price" => 3.99), 'prodname');

$table        table name
$fieldArray    associative array of data (you must quote strings yourself).
$keyCol        the primary key field name or if compound key, array of field names
autoQuote        set to true to use a heuristic to quote strings. Works with nulls and numbers
but does not work with dates nor SQL functions.
has_autoinc    the primary key is an auto-inc field, so skip in insert.

Currently blob replace not supported

returns 0 = fail, 1 = update, 2 = insert

CacheSelectLimit($secs2cache,$sql,$nrows=-1,$offset=-1,$inputarr=false)   X-Ref
Will select, getting rows from $offset (1-based), for $nrows.
This simulates the MySQL "select * from table limit $offset,$nrows" , and
the PostgreSQL "select * from table limit $nrows offset $offset". Note that
MySQL and PostgreSQL parameter ordering is the opposite of the other.
eg.
CacheSelectLimit(15,'select * from table',3); will return rows 1 to 3 (1-based)
CacheSelectLimit(15,'select * from table',3,2); will return rows 3 to 5 (1-based)

BUG: Currently CacheSelectLimit fails with $sql with LIMIT or TOP clause already set

param: int    $secs2cache Seconds to cache data, set to 0 to force query. This is optional
param: string $sql
param: int    $offset     Row to start calculations from (1-based)
param: int    $nrows      Number of rows to get
param: array $inputarr    Array of bind variables
return: ADORecordSet The recordset ($rs->databaseType == 'array')

CacheFlush($sql=false,$inputarr=false)   X-Ref
Flush cached recordsets that match a particular $sql statement.
If $sql == false, then we purge all files in the cache.


_gencachename($sql,$createdir)   X-Ref
Private function to generate filename for caching.
Filename is generated based on:

- sql statement
- database type (oci8, ibase, ifx, etc)
- database name
- userid
- setFetchMode (adodb 4.23)

When not in safe mode, we create 256 sub-directories in the cache directory ($ADODB_CACHE_DIR).
Assuming that we can have 50,000 files per directory with good performance,
then we can scale to 12.8 million unique cached recordsets. Wow!

CacheExecute($secs2cache,$sql=false,$inputarr=false)   X-Ref
Execute SQL, caching recordsets.

param: int         $secs2cache Seconds to cache data, set to 0 to force query.
param: string|bool $sql        SQL statement to execute
param: array|bool  $inputarr   Holds the input data to bind
return: ADORecordSet RecordSet or false

AutoExecute($table, $fields_values, $mode = 'INSERT', $where = false, $forceUpdate = true, $magic_quotes = false)   X-Ref
Similar to PEAR DB's autoExecute(), except that $mode can be 'INSERT'
or 'UPDATE' or DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE.
If $mode == 'UPDATE', then $where is compulsory as a safety measure.

param: $table
param: $fields_values
param: string $mode
param: false $where
param: bool $forceUpdate  If true, perform update even if the data has not changed.
param: bool $magic_quotes This param is not used since 5.21.0.
return: bool

GetUpdateSQL(&$rs, $arrFields, $forceUpdate=false, $magic_quotes=false, $force=null)   X-Ref
Generates an Update Query based on an existing recordset.

$arrFields is an associative array of fields with the value
that should be assigned.

Note: This function should only be used on a recordset
that is run against a single table and sql should only
be a simple select stmt with no groupby/orderby/limit
author: "Jonathan Younger" <jyounger@unilab.com>
param: $rs
param: $arrFields
param: bool $forceUpdate
param: bool $magic_quotes This param is not used since 5.21.0.
param: null $force
return: false|string

GetInsertSQL(&$rs, $arrFields, $magic_quotes=false, $force=null)   X-Ref
Generates an Insert Query based on an existing recordset.

$arrFields is an associative array of fields with the value
that should be assigned.

Note: This function should only be used on a recordset
that is run against a single table.

param: $rs
param: $arrFields
param: bool $magic_quotes This param is not used since 5.21.0.
param: null $force
return: false|string

UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')   X-Ref
Update a blob column, given a where clause. There are more sophisticated
blob handling functions that we could have implemented, but all require
a very complex API. Instead we have chosen something that is extremely
simple to understand and use.

Note: $blobtype supports 'BLOB' and 'CLOB', default is BLOB of course.

Usage to update a $blobvalue which has a primary key blob_id=1 into a
field blobtable.blobcolumn:

UpdateBlob('blobtable', 'blobcolumn', $blobvalue, 'blob_id=1');

Insert example:

$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
$conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');

UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB')   X-Ref
Usage:
UpdateBlob('TABLE', 'COLUMN', '/path/to/file', 'ID=1');

$blobtype supports 'BLOB' and 'CLOB'

$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
$conn->UpdateBlob('blobtable','blobcol',$blobpath,'id=1');

BlobDecode($blob)   X-Ref
No description

BlobEncode($blob)   X-Ref
No description

GetCharSet()   X-Ref
No description

SetCharSet($charset)   X-Ref
No description

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

LogSQL($enable=true)   X-Ref
No description

UpdateClob($table,$column,$val,$where)   X-Ref
Usage:
UpdateClob('TABLE', 'COLUMN', $var, 'ID=1', 'CLOB');

$conn->Execute('INSERT INTO clobtable (id, clobcol) VALUES (1, null)');
$conn->UpdateClob('clobtable','clobcol',$clob,'id=1');

MetaType($t,$len=-1,$fieldobj=false)   X-Ref
No description

SetDateLocale($locale = 'En')   X-Ref
Change the SQL connection locale to a specified locale.
This is used to get the date formats written depending on the client locale.


GetActiveRecordsClass($class, $table,$whereOrderBy=false,$bindarr=false, $primkeyArr=false,$extra=array()   X-Ref
GetActiveRecordsClass Performs an 'ALL' query

param: mixed $class This string represents the class of the current active record
param: mixed $table Table used by the active record object
param: mixed $whereOrderBy Where, order, by clauses
param: mixed $bindarr
param: mixed $primkeyArr
param: array $extra Query extras: limit, offset...
param: mixed $relations Associative array: table's foreign name, "hasMany", "belongsTo"
return: void

GetActiveRecords($table,$where=false,$bindarr=false,$primkeyArr=false)   X-Ref
No description

Close()   X-Ref
Close Connection


BeginTrans()   X-Ref
Begin a Transaction. Must be followed by CommitTrans() or RollbackTrans().

return: bool true if succeeded or false if database does not support transactions

SetTransactionMode( $transaction_mode )   X-Ref
No description

MetaTransaction($mode,$db)   X-Ref
No description

CommitTrans($ok=true)   X-Ref
If database does not support transactions, always return true as data always committed

param: bool $ok  set to false to rollback transaction, true to commit
return: true/false.

RollbackTrans()   X-Ref
If database does not support transactions, rollbacks always fail, so return false

return: bool

MetaDatabases()   X-Ref
return the databases that the driver can connect to.
Some databases will return an empty array.

return: array|bool an array of database names.

MetaProcedures($procedureNamePattern = null, $catalog = null, $schemaPattern = null)   X-Ref
List procedures or functions in an array.

param: procedureNamePattern  a procedure name pattern; must match the procedure name as it is stored in the database
param: catalog a catalog name; must match the catalog name as it is stored in the database;
param: schemaPattern a schema name pattern;
return: array of procedures on current database.

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

param: ttype can either be 'VIEW' or 'TABLE' or false.
param: showSchema returns the schema/user with the table name, eg. USER.TABLE
param: mask  is the input mask - only supported by oci8 and postgresql
return: array of tables for current database.

_findschema(&$table,&$schema)   X-Ref
No description

MetaColumns($table,$normalize=true)   X-Ref
List columns in a database as an array of ADOFieldObjects.
See top of file for definition of object.

param: $table    table name to query
param: $normalize    makes table name case-insensitive (required by some databases)
return: array of ADOFieldObjects for current table.

MetaIndexes($table, $primary = false, $owner = false)   X-Ref
List indexes on a table as an array.

param: table  table name to query
param: primary true to only show primary keys. Not actually used for most databases
return: array of indexes on current table. Each element represents an index, and is itself an associative array.

MetaColumnNames($table, $numIndexes=false,$useattnum=false )   X-Ref
List columns names in a table as an array.

param: table    table name to query
return: array of column names for current table.

Concat()   X-Ref
Concatenate strings.

Different SQL databases used different methods to combine strings together.
This function provides a wrapper.

Usage: $db->Concat($str1,$str2);

param: string $s Variable number of string parameters
return: string concatenated string

DBDate($d, $isfld=false)   X-Ref
Converts a date "d" to a string that the database can understand.

param: mixed $d a date in Unix date time format.
return: string date string in database date format

BindDate($d)   X-Ref
No description

BindTimeStamp($d)   X-Ref
No description

DBTimeStamp($ts,$isfld=false)   X-Ref
Converts a timestamp "ts" to a string that the database can understand.

param: int|object $ts A timestamp in Unix date time format.
return: string $timestamp string in database timestamp format

UnixDate($v)   X-Ref
Also in ADORecordSet.

param: mixed $v is a date string in YYYY-MM-DD format
return: int|false Date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format

UnixTimeStamp($v)   X-Ref
Also in ADORecordSet.

param: string|object $v is a timestamp string in YYYY-MM-DD HH-NN-SS format
return: int|false Date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format

UserDate($v,$fmt='Y-m-d',$gmt=false)   X-Ref
Format database date based on user defined format.

Also in ADORecordSet.

param: mixed  $v    Date in YYYY-MM-DD format, returned by database
param: string $fmt  Format to apply, using date()
param: bool   $gmt
return: string Formatted date

UserTimeStamp($v,$fmt='Y-m-d H:i:s',$gmt=false)   X-Ref
Format timestamp based on user defined format.

param: mixed  $v    Date in YYYY-MM-DD hh:mm:ss format
param: string $fmt  Format to apply, using date()
param: bool   $gmt
return: string Formatted timestamp

escape($s,$magic_quotes=false)   X-Ref
Alias for addQ()

param: string $s
param: bool [$magic_quotes]
return: mixed

addQ($s, $magic_quotes=false)   X-Ref
Quotes a string, without prefixing nor appending quotes.

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

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

PageExecute($sql, $nrows, $page, $inputarr=false, $secs2cache=0)   X-Ref
Will select the supplied $page number from a recordset, given that it is paginated in pages of
$nrows rows per page. It also saves two boolean values saying if the given page is the first
and/or last one of the recordset. Added by Iván Oliva to provide recordset pagination.

See docs-adodb.htm#ex8 for an example of usage.
NOTE: phpLens uses a different algorithm and does not use PageExecute().

param: string $sql
param: int    $nrows          Number of rows per page to get
param: int    $page           Page number to get (1-based)
param: mixed[]|bool $inputarr Array of bind variables
param: int    $secs2cache     Private parameter only used by jlim
return: mixed        the recordset ($rs->databaseType == 'array')

CachePageExecute($secs2cache, $sql, $nrows, $page,$inputarr=false)   X-Ref
Will select the supplied $page number from a recordset, given that it is paginated in pages of
$nrows rows per page. It also saves two boolean values saying if the given page is the first
and/or last one of the recordset. Added by Iván Oliva to provide recordset pagination.

param: int $secs2cache    seconds to cache data, set to 0 to force query
param: string $sql
param: int $nrows        is the number of rows per page to get
param: int $page        is the page number to get (1-based)
param: mixed[]|bool $inputarr    array of bind variables
return: mixed    the recordset ($rs->databaseType == 'array')

charMax()   X-Ref
Returns the maximum size of a MetaType C field. If the method
is not defined in the driver returns ADODB_STRINGMAX_NOTSET

return: int

textMax()   X-Ref
Returns the maximum size of a MetaType X field. If the method
is not defined in the driver returns ADODB_STRINGMAX_NOTSET

return: int

substr($fld,$start,$length=0)   X-Ref
Returns a substring of a varchar type field

Some databases have variations of the parameters, which is why
we have an ADOdb function for it

param: string    $fld    The field to sub-string
param: int        $start    The start point
param: int        $length    An optional length
return: string    The SQL text

month($fld)   X-Ref
No description

day($fld)   X-Ref
No description

year($fld)   X-Ref
No description

resetLastError()   X-Ref
Get the last error recorded by PHP and clear the message.

By clearing the message, it becomes possible to detect whether a new error
has occurred, even when it is the same error as before being repeated.

return: mixed[]|null Array if an error has previously occurred. Null otherwise.

getChangedErrorMsg($old = null)   X-Ref
Compare a previously stored error message with the last error recorded by PHP
to determine whether a new error has occurred.

param: mixed[]|null $old Optional. Previously stored return value of error_get_last().
return: string The error message if a new error has occurred

Class: ADOFetchObj  - X-Ref

Internal placeholder for record objects. Used by ADORecordSet->FetchObj().

Class: ADODB_Iterator_empty  - X-Ref

__construct($rs)   X-Ref
No description

rewind()   X-Ref
No description

valid()   X-Ref
No description

key()   X-Ref
No description

current()   X-Ref
No description

next()   X-Ref
No description

__call($func, $params)   X-Ref
No description

hasMore()   X-Ref
No description

Class: ADORecordSet_empty  - X-Ref

Lightweight recordset when there are no records to be returned

RowCount()   X-Ref
No description

RecordCount()   X-Ref
No description

PO_RecordCount()   X-Ref
No description

Close()   X-Ref
No description

FetchRow()   X-Ref
No description

FieldCount()   X-Ref
No description

Init()   X-Ref
No description

getIterator()   X-Ref
No description

GetAssoc()   X-Ref
No description

GetArray()   X-Ref
No description

GetAll()   X-Ref
No description

GetArrayLimit()   X-Ref
No description

GetRows()   X-Ref
No description

GetRowAssoc()   X-Ref
No description

MaxRecordCount()   X-Ref
No description

NumRows()   X-Ref
No description

NumCols()   X-Ref
No description

Class: ADODB_Iterator  - X-Ref

__construct($rs)   X-Ref
No description

rewind()   X-Ref
No description

valid()   X-Ref
No description

key()   X-Ref
No description

current()   X-Ref
No description

next()   X-Ref
No description

__call($func, $params)   X-Ref
No description

hasMore()   X-Ref
No description

Class: ADORecordSet  - X-Ref

RecordSet class that represents the dataset returned by the database.
To keep memory overhead low, this class holds only the current row in memory.
No prefetching of data is done, so the RecordCount() can return -1 ( which
means recordcount not known).

__construct($queryID)   X-Ref
Constructor

param: resource|int queryID    this is the queryID returned by ADOConnection->_query()

__destruct()   X-Ref
No description

getIterator()   X-Ref
No description

__toString()   X-Ref
No description

Init()   X-Ref
No description

getMenu($name, $defstr = '', $blank1stItem = true, $multiple = false,$size = 0, $selectAttr = '', $compareFirstCol = true)   X-Ref
Generate a SELECT tag from a recordset, and return the HTML markup.

If the recordset has 2 columns, we treat the first one as the text to
display to the user, and the second as the return value. Extra columns
are discarded.

param: string       $name            Name of SELECT tag
param: string|array $defstr          The value to highlight. Use an array for multiple highlight values.
param: bool|string $blank1stItem     True to create an empty item (default), False not to add one;
param: bool         $multiple        True for multi-select list
param: int          $size            Number of rows to show (applies to multi-select box only)
param: string       $selectAttr      Additional attributes to defined for SELECT tag,
param: bool         $compareFirstCol When true (default), $defstr is compared against the value (column 2),
return: string HTML

getMenuGrouped($name, $defstr = '', $blank1stItem = true, $multiple = false,$size = 0, $selectAttr = '', $compareFirstCol = true)   X-Ref
Generate a SELECT tag with groups from a recordset, and return the HTML markup.

The recordset must have 3 columns and be ordered by the 3rd column. The
first column contains the text to display to the user, the second is the
return value and the third is the option group. Extra columns are discarded.
Default strings are compared with the SECOND column.

param: string       $name            Name of SELECT tag
param: string|array $defstr          The value to highlight. Use an array for multiple highlight values.
param: bool|string $blank1stItem     True to create an empty item (default), False not to add one;
param: bool         $multiple        True for multi-select list
param: int          $size            Number of rows to show (applies to multi-select box only)
param: string       $selectAttr      Additional attributes to defined for SELECT tag,
param: bool         $compareFirstCol When true (default), $defstr is compared against the value (column 2),
return: string HTML

getMenu2($name, $defstr = '', $blank1stItem = true, $multiple = false,$size = 0, $selectAttr = '')   X-Ref
Generate a SELECT tag from a recordset, and return the HTML markup.

Same as GetMenu(), except that default strings are compared with the
FIRST column (the description).

param: string       $name            Name of SELECT tag
param: string|array $defstr          The value to highlight. Use an array for multiple highlight values.
param: bool|string $blank1stItem     True to create an empty item (default), False not to add one;
param: bool         $multiple        True for multi-select list
param: int          $size            Number of rows to show (applies to multi-select box only)
param: string       $selectAttr      Additional attributes to defined for SELECT tag,
return: string HTML

getMenu3($name, $defstr = '', $blank1stItem = true, $multiple = false,$size = 0, $selectAttr = '')   X-Ref
Generate a SELECT tag with groups from a recordset, and return the HTML markup.

Same as GetMenuGrouped(), except that default strings are compared with the
FIRST column (the description).

param: string       $name            Name of SELECT tag
param: string|array $defstr          The value to highlight. Use an array for multiple highlight values.
param: bool|string $blank1stItem     True to create an empty item (default), False not to add one;
param: bool         $multiple        True for multi-select list
param: int          $size            Number of rows to show (applies to multi-select box only)
param: string       $selectAttr      Additional attributes to defined for SELECT tag,
return: string HTML

GetArray($nRows = -1)   X-Ref
return recordset as a 2-dimensional array.

param: int $nRows  Number of rows to return. -1 means every row.
return: array indexed by the rows (0-based) from the recordset

GetAll($nRows = -1)   X-Ref
No description

NextRecordSet()   X-Ref
No description

GetArrayLimit($nrows,$offset=-1)   X-Ref
return recordset as a 2-dimensional array.
Helper function for ADOConnection->SelectLimit()

param: offset    is the row to start calculations from (1-based)
param: [nrows]    is the number of rows to return
return: array an array indexed by the rows (0-based) from the recordset

GetRows($nRows = -1)   X-Ref
Synonym for GetArray() for compatibility with ADO.

param: [nRows]  is the number of rows to return. -1 means every row.
return: array an array indexed by the rows (0-based) from the recordset

getAssoc($force_array = false, $first2cols = false)   X-Ref
return whole recordset as a 2-dimensional associative array if
there are more than 2 columns. The first column is treated as the
key and is not included in the array. If there is only 2 columns,
it will return a 1 dimensional array of key-value pairs unless
$force_array == true. This recordset method is currently part of
the API, but may not be in later versions of ADOdb. By preference, use
ADOconnnection::getAssoc()

param: bool    $force_array    (optional) Has only meaning if we have 2 data
param: bool    $first2cols     (optional) Means if there are more than
return: mixed[]|false

UserTimeStamp($v,$fmt='Y-m-d H:i:s')   X-Ref

param: mixed $v        is the character timestamp in YYYY-MM-DD hh:mm:ss format
param: string [$fmt]    is the format to apply to it, using date()
return: string a timestamp formated as user desires

UserDate($v,$fmt='Y-m-d')   X-Ref

param: mixed $v        is the character date in YYYY-MM-DD format, returned by database
param: string $fmt    is the format to apply to it, using date()
return: string a date formatted as user desires

UnixDate($v)   X-Ref

param: mixed $v is a date string in YYYY-MM-DD format
return: string date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format

UnixTimeStamp($v)   X-Ref

param: string|object $v is a timestamp string in YYYY-MM-DD HH-NN-SS format
return: mixed date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format

Free()   X-Ref
PEAR DB Compat - do not use internally


NumRows()   X-Ref
PEAR DB compat, number of rows

return: int

NumCols()   X-Ref
PEAR DB compat, number of cols

return: int

FetchRow()   X-Ref
Fetch a row, returning false if no more rows.
This is PEAR DB compat mode.

return: mixed[]|false false or array containing the current record

FetchInto(&$arr)   X-Ref
Fetch a row, returning PEAR_Error if no more rows.
This is PEAR DB compat mode.

param: mixed[]|false $arr
return: mixed DB_OK or error object

MoveFirst()   X-Ref
Move to the first row in the recordset. Many databases do NOT support this.

return: bool true or false

MoveLast()   X-Ref
Move to the last row in the recordset.

return: bool true or false

MoveNext()   X-Ref
Move to next record in the recordset.

return: bool true if there still rows available, or false if there are no more rows (EOF).

Move($rowNumber = 0)   X-Ref
Random access to a specific row in the recordset. Some databases do not support
access to previous rows in the databases (no scrolling backwards).

param: int $rowNumber is the row to move to (0-based)
return: bool true if there still rows available, or false if there are no more rows (EOF).

Fields($colname)   X-Ref
Get the value of a field in the current row by column name.
Will not work if ADODB_FETCH_MODE is set to ADODB_FETCH_NUM.

param: string $colname is the field to access
return: mixed the value of $colname column

AssocCaseConvertFunction($case = ADODB_ASSOC_CASE)   X-Ref
Defines the function to use for table fields case conversion
depending on ADODB_ASSOC_CASE

param: int [$case]
return: string strtolower/strtoupper or false if no conversion needed

GetAssocKeys($upper = ADODB_ASSOC_CASE)   X-Ref
Builds the bind array associating keys to recordset fields

param: int [$upper] Case for the array keys, defaults to uppercase

GetRowAssoc($upper = ADODB_ASSOC_CASE)   X-Ref
Use associative array to get fields array for databases that do not support
associative arrays. Submitted by Paolo S. Asioli paolo.asioli#libero.it

param: int [$upper] Case for the array keys, defaults to uppercase

Close()   X-Ref
Clean up recordset

return: bool

RecordCount()   X-Ref
Synonyms RecordCount and RowCount

return: int Number of rows or -1 if this is not supported

MaxRecordCount()   X-Ref
If we are using PageExecute(), this will return the maximum possible rows
that can be returned when paging a recordset.

return: int

RowCount()   X-Ref
synonyms RecordCount and RowCount

return: the number of rows or -1 if this is not supported

PO_RecordCount($table="", $condition="")   X-Ref
Portable RecordCount. Pablo Roca <pabloroca@mvps.org>

return: the number of records from a previous SELECT. All databases support this.

CurrentRow()   X-Ref

return: the current row in the recordset. If at EOF, will return the last row. 0-based.

AbsolutePosition()   X-Ref
synonym for CurrentRow -- for ADO compat

return: the current row in the recordset. If at EOF, will return the last row. 0-based.

FieldCount()   X-Ref

return: the number of columns in the recordset. Some databases will set this to 0

FetchField($fieldoffset = -1)   X-Ref
Get the ADOFieldObject of a specific column.

param: fieldoffset    is the column position to access(0-based).
return: the ADOFieldObject for that column, or false.

FieldTypesArray()   X-Ref
Get the ADOFieldObjects of all columns in an array.


FetchObj()   X-Ref
Return the fields array of the current row as an object for convenience.
The default case is lowercase field names.

return: the object with the properties set to the fields of the current row

FetchObject($isupper=true)   X-Ref
Return the fields array of the current row as an object for convenience.
The default case is uppercase.

param: $isupper to set the object property names to uppercase
return: the object with the properties set to the fields of the current row

FetchNextObj()   X-Ref
Return the fields array of the current row as an object for convenience.
The default is lower-case field names.

return: the object with the properties set to the fields of the current row,

FetchNextObject($isupper=true)   X-Ref
Return the fields array of the current row as an object for convenience.
The default is upper case field names.

param: $isupper to set the object property names to uppercase
return: the object with the properties set to the fields of the current row,

MetaType($t,$len=-1,$fieldobj=false)   X-Ref
Get the metatype of the column. This is used for formatting. This is because
many databases use different names for the same type, so we transform the original
type to our standardised version which uses 1 character codes:

param: t  is the type passed in. Normally is ADOFieldObject->type.
param: len is the maximum length of that field. This is because we treat character
param: fieldobj is the field object returned by the database driver. Can hold
return: the general type of the data:

_updatefields()   X-Ref
Convert case of field names associative array, if needed

return: void

_close()   X-Ref
No description

AbsolutePage($page=-1)   X-Ref
set/returns the current recordset page when paginating


AtFirstPage($status=false)   X-Ref
set/returns the status of the atFirstPage flag when paginating


LastPageNo($page = false)   X-Ref
No description

AtLastPage($status=false)   X-Ref
set/returns the status of the atLastPage flag when paginating


Class: ADORecordSet_array  - X-Ref

This class encapsulates the concept of a recordset created in memory
as an array. This is useful for the creation of cached recordsets.

Note that the constructor is different from the standard ADORecordSet
__construct($fakeid=1)   X-Ref
Constructor


_transpose($addfieldnames=true)   X-Ref
No description

InitArray($array,$typearr,$colnames=false)   X-Ref
Setup the array.

param: array        is a 2-dimensional array holding the data.
param: typearr    holds an array of types. These are the same types
param: string[]|false [$colnames]    array of column names. If set, then the first row of

InitArrayFields(&$array,&$fieldarr)   X-Ref
Setup the Array and datatype file objects

param: array $array    2-dimensional array holding the data
param: array $fieldarr Array of ADOFieldObject's.

GetArray($nRows=-1)   X-Ref

param: int [$nRows]
return: array

_initrs()   X-Ref
No description

Fields($colname)   X-Ref
Use associative array to get fields array

param: string $colname
return: mixed

FetchField($fieldOffset = -1)   X-Ref

param: int [$fieldOffset]
return: \ADOFieldObject

_seek($row)   X-Ref

param: int $row
return: bool

MoveNext()   X-Ref

return: bool

_fetch()   X-Ref

return: bool

_close()   X-Ref
No description

ADOLoadDB($dbType)   X-Ref
Synonym for ADOLoadCode. Private function. Do not use.


ADOLoadCode($dbType)   X-Ref
Load the code for a specific database driver. Private function. Do not use.


NewADOConnection($db='')   X-Ref
Synonym for ADONewConnection for people like me who cannot remember the correct name

param: string [$db]
return: ADOConnection|false

ADONewConnection($db='')   X-Ref
Instantiate a new Connection class for a specific database driver.

param: string $db Database Connection object to create. If undefined,
return: ADOConnection|false The freshly created instance of the Connection class

_adodb_getdriver($provider,$drivername,$perf=false)   X-Ref
No description

NewPerfMonitor(&$conn)   X-Ref
No description

NewDataDictionary(&$conn,$drivername=false)   X-Ref
No description

adodb_pr($var,$as_string=false)   X-Ref
No description

adodb_backtrace($printOrArr=true,$levels=9999,$ishtml=null)   X-Ref
No description

Functions that are not part of a class:

ADODB_Setup()   X-Ref
No description