Class ADOConnection

Description

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

Located in /3rd/adodb/adodb.inc.php (line 233)


	
			
Direct descendents
Class Description
 class Connection object. For connecting to databases, and executing queries.
 class ADODB_csv Connection object. For connecting to databases, and executing queries.
 class ADODB_fbsql Connection object. For connecting to databases, and executing queries.
 class ADODB_ibase Connection object. For connecting to databases, and executing queries.
 class ADODB_informix72 Connection object. For connecting to databases, and executing queries.
 class ADODB_ldap Connection object. For connecting to databases, and executing queries.
 class ADODB_mssql Connection object. For connecting to databases, and executing queries.
 class ADODB_mysql Connection object. For connecting to databases, and executing queries.
 class ADODB_mysqli Connection object. For connecting to databases, and executing queries.
 class ADODB_oci8 Connection object. For connecting to databases, and executing queries.
 class ADODB_odbc Connection object. For connecting to databases, and executing queries.
 class ADODB_odbtp Connection object. For connecting to databases, and executing queries.
 class ADODB_oracle Connection object. For connecting to databases, and executing queries.
 class ADODB_pdo Connection object. For connecting to databases, and executing queries.
 class ADODB_postgres64 Connection object. For connecting to databases, and executing queries.
 class ADODB_sqlite Connection object. For connecting to databases, and executing queries.
 class ADODB_sybase Connection object. For connecting to databases, and executing queries.
Variable Summary
Method Summary
 ADOConnection ADOConnection ()
 void addq ( $s, [ $magic_quotes = false])
 void &AutoExecute ( $table,  $fields_values, [ $mode = 'INSERT'], [ $where = FALSE], [ $forceUpdate = true], [ $magicq = false])
 true BeginTrans ()
 void BlobDecode ( $blob)
 void BlobEncode ( $blob)
 RecordSet &CacheExecute ([secs2cache] $secs2cache, [sql $sql = false], [[inputarr] $inputarr = false])
 void CacheFlush ([ $sql = false], [ $inputarr = false])
 void &CacheGetAll ( $secs2cache, [ $sql = false], [ $inputarr = false])
 void &CacheGetArray ( $secs2cache, [ $sql = false], [ $inputarr = false])
 void &CacheGetAssoc ( $secs2cache, [ $sql = false], [ $inputarr = false], [ $force_array = false], [ $first2cols = false])
 void CacheGetCol ( $secs, [ $sql = false], [ $inputarr = false], [ $trim = false])
 void CacheGetOne ( $secs2cache, [ $sql = false], [ $inputarr = false])
 void &CacheGetRow ( $secs2cache, [ $sql = false], [ $inputarr = false])
 the &CachePageExecute (secs2cache $secs2cache, sql $sql, nrows $nrows, page $page, [[inputarr] $inputarr = false])
 the &CacheSelectLimit ([secs2cache] $secs2cache, sql $sql, [[offset] $nrows = -1], [[nrows] $offset = -1], [[inputarr] $inputarr = false])
 void Close ()
 void CommitLock ( $table)
 true/false. CommitTrans ([$ok $ok = true])
 void CompleteTrans ([ $autoComplete = true])
 concatenated Concat ()
 true Connect ([[argHostname] $argHostname = ""], [[argUsername] $argUsername = ""], [[argPassword] $argPassword = ""], [[argDatabaseName] $argDatabaseName = ""], [[forceNew] $forceNew = false])
 void CreateSequence ([ $seqname = 'adodbseq'], [ $startID = 1])
 date DBDate (d $d)
 timestamp DBTimeStamp (ts $ts)
 void Disconnect ()
 void DropSequence ([ $seqname = 'adodbseq'])
 the ErrorMsg ()
 void ErrorNative ()
 the ErrorNo ()
 void escape ( $s, [ $magic_quotes = false])
 RecordSet &Execute (sql $sql, [[inputarr] $inputarr = false])
 void FailTrans ()
 GenID ([seqname $seqname = 'adodbseq'], [startID $startID = 1])
 void &GetAll ( $sql, [ $inputarr = false])
 void &GetArray (sql $sql, [[inputarr] $inputarr = false])
 void &GetAssoc ( $sql, [ $inputarr = false], [ $force_array = false], [ $first2cols = false])
 void GetCharSet ()
 void GetCol ( $sql, [ $inputarr = false], [ $trim = false])
 void GetInsertSQL ( &$rs,  $arrFields, [ $magicq = false], [ $force = null])
 void GetOne (sql $sql, [[inputarr] $inputarr = false])
 void &GetRow (sql $sql, [[inputarr] $inputarr = false])
 void GetUpdateSQL ( &$rs,  $arrFields, [ $forceUpdate = false], [ $magicq = false], [ $force = null])
 void HasFailedTrans ()
 void IfNull ( $field,  $ifNull)
 void InParameter ( &$stmt,  &$var,  $name, [ $maxLen = 4000], [ $type = false])
 the Insert_ID ([$table $table = ''], [$column $column = ''])
 void IsConnected ()
 void &LimitQuery ( $sql,  $offset,  $count, [ $params = false])
 void LogSQL ([ $enable = true])
 array &MetaColumnNames (table $table, [ $numIndexes = false])
 array &MetaColumns (table $table, [upper $upper = true])
 void MetaError ([ $err = false])
 void MetaErrorMsg ( $errno)
 assoc MetaForeignKeys ( $table, [ $owner = false], [ $upper = false])
 array &MetaIndexes (table $table, [primary $primary = false], [ $owner = false])
 an MetaPrimaryKeys ( $table, [ $owner = false])
 array &MetaTables ([ttype $ttype = false], [showSchema $showSchema = false], [mask $mask = false])
 void MetaType ( $t, [ $len = -1], [ $fieldobj = false])
 true NConnect ([[argHostname] $argHostname = ""], [[argUsername] $argUsername = ""], [[argPassword] $argPassword = ""], [[argDatabaseName] $argDatabaseName = ""])
 void nextId ( $seq_name)
 void OffsetDate ( $dayFraction, [ $date = false])
 void outp ( $msg, [ $newline = true])
 void OutParameter ( &$stmt,  &$var,  $name, [ $maxLen = 4000], [ $type = false])
 the &PageExecute (sql $sql, nrows $nrows, page $page, [[inputarr] $inputarr = false], [[secs2cache] $secs2cache = 0])
 void Param ( $name, [ $type = 'C'])
 void Parameter ( &$stmt,  &$var,  $name, [ $isOutput = false], [ $maxLen = 4000], [ $type = false])
 return PConnect ([[argHostname] $argHostname = ""], [[argUsername] $argUsername = ""], [[argPassword] $argPassword = ""], [[argDatabaseName] $argDatabaseName = ""])
 the PO_Insert_ID ([ $table = ""], [ $id = ""])
 return Prepare (sql $sql)
 return PrepareSP (sql $sql, [ $param = true])
 void q ( &$s)
 void QMagic ( $s)
 quoted qstr (s $s, [[magic_quotes] $magic_quotes = false])
 void &Query ( $sql, [ $inputarr = false])
 void Quote ( $s)
 void Replace ( $table,  $fieldArray,  $keyCol, [ $autoQuote = false], [ $has_autoinc = false])
 void RollbackLock ( $table)
 true/false. RollbackTrans ()
 void RowLock ($table $table, $where $where)
 true SelectDB (dbName $dbName)
 the &SelectLimit (sql $sql, [[offset] $nrows = -1], [[nrows] $offset = -1], [[inputarr] $inputarr = false], [[secs2cache] $secs2cache = 0])
 void &SerializableRS (rs &$rs)
 void ServerInfo ()
 void SetCharSet ( $charset)
 void SetDateLocale ([ $locale = 'En'])
 The SetFetchMode (mode $mode)
 void SQLDate ( $fmt, [ $col = false])
 void StartTrans ([ $errfn = 'ADODB_TransMonitor'])
 void Time ()
 date UnixDate ($v $v)
 date UnixTimeStamp ($v $v)
 void UpdateBlob ( $table,  $column,  $val,  $where, [ $blobtype = 'BLOB'])
 void UpdateBlobFile ( $table,  $column,  $path,  $where, [ $blobtype = 'BLOB'])
 void UpdateClob ( $table,  $column,  $val,  $where)
 a UserDate (v $v, [fmt $fmt = 'Y-m-d'], [ $gmt = false])
 a UserTimeStamp (v $v, [fmt $fmt = 'Y-m-d H:i:s'], [ $gmt = false])
 void Version ()
 void &_Execute ( $sql, [ $inputarr = false])
 void _findschema ( &$table,  &$schema)
 void _findvers ( $str)
 void _gencachename ( $sql,  $createdir)
 void _nconnect ( $argHostname,  $argUsername,  $argPassword,  $argDatabaseName)
 the &_rs2rs (rs &$rs, [[nrows] $nrows = -1], [[offset] $offset = -1], [ $close = true])
Variables
mixed $arrayClass = 'ADORecordSet_array' (line 279)

Redefined in descendants as:
mixed $autoCommit = true (line 297)
mixed $autoRollback = false (line 289)

Redefined in descendants as:
mixed $cacheSecs = 3600 (line 276)
mixed $charSet = false (line 256)

Redefined in descendants as:
mixed $database = '' (line 239)
mixed $debug = false (line 243)
mixed $emptyDate = ' ' (line 260)
mixed $emptyTimeStamp = ' ' (line 261)
mixed $false = '0' (line 253)

Redefined in descendants as:
mixed $fetchMode = false (line 301)
mixed $fnCacheExecute = false (line 293)
mixed $fnExecute = false (line 292)
mixed $genID = 0 (line 273)
mixed $host = '' (line 240)
mixed $lastInsID = false (line 262)
mixed $leftOuter = false (line 286)

Redefined in descendants as:
mixed $length = 'length' (line 247)

Redefined in descendants as:
mixed $maxblobsize = 262144 (line 244)
mixed $nameQuote = '"' (line 255)

Redefined in descendants as:
mixed $noNullStrings = false (line 281)

Redefined in descendants as:
mixed $numCacheHits = 0 (line 282)
mixed $numCacheMisses = 0 (line 283)
mixed $pageExecuteCountRows = true (line 284)
mixed $password = '' (line 242)

Redefined in descendants as:
mixed $raiseErrorFn = false (line 274)
mixed $readOnly = false (line 268)
mixed $rightOuter = false (line 287)

Redefined in descendants as:
mixed $rsPrefix = "ADORecordSet_" (line 295)
mixed $transCnt = 0 (line 299)
mixed $transOff = 0 (line 298)
mixed $true = '1' (line 252)

Redefined in descendants as:
mixed $uniqueOrderBy = false (line 259)

Redefined in descendants as:
mixed $uniqueSort = false (line 285)

Redefined in descendants as:
mixed $upperCase = 'upper' (line 249)
mixed $user = '' (line 241)
mixed $_affected = false (line 316)
mixed $_connectionID = false (line 307)
mixed $_errorCode = false (line 310)
mixed $_errorMsg = false (line 308)
mixed $_evalAll = false (line 315)
mixed $_isPersistentConnection = false (line 313)
mixed $_logsql = false (line 317)
mixed $_oldRaiseFn = false (line 305)
mixed $_queryID = false (line 311)
mixed $_transOK = null (line 306)
Methods
Constructor ADOConnection (line 324)

Constructor

ADOConnection ADOConnection ()
addq (line 2288)

Quotes a string, without prefixing nor appending quotes.

void addq ( $s, [ $magic_quotes = false])
  • $s
  • $magic_quotes
Affected_Rows (line 995)
  • return: rows affected by UPDATE/DELETE
# Affected_Rows ()
AutoExecute (line 1672)
void &AutoExecute ( $table,  $fields_values, [ $mode = 'INSERT'], [ $where = FALSE], [ $forceUpdate = true], [ $magicq = false])
  • $table
  • $fields_values
  • $mode
  • $where
  • $forceUpdate
  • $magicq
BlobDecode (line 1799)
void BlobDecode ( $blob)
  • $blob

Redefined in descendants as:
BlobEncode (line 1804)
void BlobEncode ( $blob)
  • $blob

Redefined in descendants as:
CacheExecute (line 1581)

Execute SQL, caching recordsets.

  • return: or false
RecordSet &CacheExecute ([secs2cache] $secs2cache, [sql $sql = false], [[inputarr] $inputarr = false])
  • [secs2cache] $secs2cache: seconds to cache data, set to 0 to force query. This is an optional parameter.
  • sql $sql: SQL statement to execute
  • [inputarr] $inputarr: holds the input data to bind to
CacheFlush (line 1502)

Flush cached recordsets that match a particular $sql statement.

If $sql == false, then we purge all files in the cache.

void CacheFlush ([ $sql = false], [ $inputarr = false])
  • $sql
  • $inputarr
CacheGetAll (line 1371)
void &CacheGetAll ( $secs2cache, [ $sql = false], [ $inputarr = false])
  • $secs2cache
  • $sql
  • $inputarr
CacheGetArray (line 1376)
void &CacheGetArray ( $secs2cache, [ $sql = false], [ $inputarr = false])
  • $secs2cache
  • $sql
  • $inputarr
CacheGetAssoc (line 1240)
void &CacheGetAssoc ( $secs2cache, [ $sql = false], [ $inputarr = false], [ $force_array = false], [ $first2cols = false])
  • $secs2cache
  • $sql
  • $inputarr
  • $force_array
  • $first2cols
CacheGetCol (line 1312)
void CacheGetCol ( $secs, [ $sql = false], [ $inputarr = false], [ $trim = false])
  • $secs
  • $sql
  • $inputarr
  • $trim
CacheGetOne (line 1278)
void CacheGetOne ( $secs2cache, [ $sql = false], [ $inputarr = false])
  • $secs2cache
  • $sql
  • $inputarr
CacheGetRow (line 1424)
void &CacheGetRow ( $secs2cache, [ $sql = false], [ $inputarr = false])
  • $secs2cache
  • $sql
  • $inputarr
CachePageExecute (line 2385)

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.

  • return: recordset ($rs->databaseType == 'array')
the &CachePageExecute (secs2cache $secs2cache, sql $sql, nrows $nrows, page $page, [[inputarr] $inputarr = false])
  • secs2cache $secs2cache: seconds to cache data, set to 0 to force query
  • sql $sql
  • nrows $nrows: is the number of rows per page to get
  • page $page: is the page number to get (1-based)
  • [inputarr] $inputarr: array of bind variables
CacheSelectLimit (line 1484)

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

  • return: recordset ($rs->databaseType == 'array')
the &CacheSelectLimit ([secs2cache] $secs2cache, sql $sql, [[offset] $nrows = -1], [[nrows] $offset = -1], [[inputarr] $inputarr = false])
  • [secs2cache] $secs2cache: seconds to cache data, set to 0 to force query. This is optional
  • sql $sql
  • [offset] $nrows: is the row to start calculations from (1-based)
  • [nrows] $offset: is the number of rows to get
  • [inputarr] $inputarr: array of bind variables
Close (line 1906)

Close Connection

void Close ()
CommitLock (line 591)
void CommitLock ( $table)
  • $table
CommitTrans (line 1928)

If database does not support transactions, always return true as data always commited

true/false. CommitTrans ([$ok $ok = true])
  • $ok $ok: set to false to rollback transaction, true to commit

Redefined in descendants as:
CompleteTrans (line 738)
void CompleteTrans ([ $autoComplete = true])
  • $autoComplete
Concat (line 2137)

Different SQL databases used different methods to combine strings together.

This function provides a wrapper.

param s variable number of string parameters

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

  • return: string
concatenated Concat ()

Redefined in descendants as:
Connect (line 405)

Connect to database

  • return: or false
true Connect ([[argHostname] $argHostname = ""], [[argUsername] $argUsername = ""], [[argPassword] $argPassword = ""], [[argDatabaseName] $argDatabaseName = ""], [[forceNew] $forceNew = false])
  • [argHostname] $argHostname: Host to connect to
  • [argUsername] $argUsername: Userid to login
  • [argPassword] $argPassword: Associated password
  • [argDatabaseName] $argDatabaseName: database
  • [forceNew] $forceNew: force new connection
CreateSequence (line 912)
void CreateSequence ([ $seqname = 'adodbseq'], [ $startID = 1])
  • $seqname
  • $startID

Redefined in descendants as:
DBDate (line 2151)

Converts a date "d" to a string that the database can understand.

  • return: string in database date format
date DBDate (d $d)
  • d $d: a date in Unix date time format.

Redefined in descendants as:
DBTimeStamp (line 2172)

Converts a timestamp "ts" to a string that the database can understand.

  • return: string in database timestamp format
timestamp DBTimeStamp (ts $ts)
  • ts $ts: a timestamp in Unix date time format.

Redefined in descendants as:
Disconnect (line 648)

PEAR DB Compat - do not use internally

void Disconnect ()
DropSequence (line 918)
void DropSequence ([ $seqname = 'adodbseq'])
  • $seqname

Redefined in descendants as:
ErrorNative (line 565)

PEAR DB Compat - do not use internally.

void ErrorNative ()
escape (line 2280)
void escape ( $s, [ $magic_quotes = false])
  • $s
  • $magic_quotes
Execute (line 793)

Execute SQL

  • return: or false
RecordSet &Execute (sql $sql, [[inputarr] $inputarr = false])
  • sql $sql: SQL statement to execute, or possibly an array holding prepared statement ($sql[0] will hold sql text)
  • [inputarr] $inputarr: holds the input data to bind to. Null elements will be set to null.

Redefined in descendants as:
FailTrans (line 765)
void FailTrans ()
GenID (line 932)

Generates a sequence id and stores it in $this->genID; GenID is only available if $this->hasGenID = true;

  • return: if not supported, otherwise a sequence id
0 GenID ([seqname $seqname = 'adodbseq'], [startID $startID = 1])
  • seqname $seqname: name of sequence to use
  • startID $startID: if sequence does not exist, start at this ID

Redefined in descendants as:
GetAll (line 1223)
void &GetAll ( $sql, [ $inputarr = false])
  • $sql
  • $inputarr
GetArray (line 1352)
void &GetArray (sql $sql, [[inputarr] $inputarr = false])
  • sql $sql: SQL statement
  • [inputarr] $inputarr: input bind array
GetAssoc (line 1229)
void &GetAssoc ( $sql, [ $inputarr = false], [ $force_array = false], [ $first2cols = false])
  • $sql
  • $inputarr
  • $force_array
  • $first2cols
GetCharSet (line 1832)
void GetCharSet ()

Redefined in descendants as:
GetCol (line 1290)
void GetCol ( $sql, [ $inputarr = false], [ $trim = false])
  • $sql
  • $inputarr
  • $trim
GetInsertSQL (line 1744)

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.

void GetInsertSQL ( &$rs,  $arrFields, [ $magicq = false], [ $force = null])
  • &$rs
  • $arrFields
  • $magicq
  • $force
GetOne (line 1262)

Return first element of first row of sql statement. Recordset is disposed for you.

void GetOne (sql $sql, [[inputarr] $inputarr = false])
  • sql $sql: SQL statement
  • [inputarr] $inputarr: input bind array

Redefined in descendants as:
GetRow (line 1404)

Return one row of sql statement. Recordset is disposed for you.

void &GetRow (sql $sql, [[inputarr] $inputarr = false])
  • sql $sql: SQL statement
  • [inputarr] $inputarr: input bind array
GetUpdateSQL (line 1716)

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

"Jonathan Younger" <jyounger@unilab.com>

void GetUpdateSQL ( &$rs,  $arrFields, [ $forceUpdate = false], [ $magicq = false], [ $force = null])
  • &$rs
  • $arrFields
  • $forceUpdate
  • $magicq
  • $force
HasFailedTrans (line 780)
void HasFailedTrans ()
InParameter (line 670)
void InParameter ( &$stmt,  &$var,  $name, [ $maxLen = 4000], [ $type = false])
  • &$stmt
  • &$var
  • $name
  • $maxLen
  • $type

Redefined in descendants as:
Insert_ID (line 965)
  • return: last inserted ID. Not all databases support this.
the Insert_ID ([$table $table = ''], [$column $column = ''])
  • $table $table: string name of the table, not needed by all databases (eg. mysql), default ''
  • $column $column: string name of the column, not needed by all databases (eg. mysql), default ''
IsConnected (line 347)
void IsConnected ()
LimitQuery (line 637)

PEAR DB Compat - do not use internally

void &LimitQuery ( $sql,  $offset,  $count, [ $params = false])
  • $sql
  • $offset
  • $count
  • $params
LogSQL (line 1819)
void LogSQL ([ $enable = true])
  • $enable
MetaColumnNames (line 2110)

List columns names in a table as an array.

  • return: of column names for current table.
array &MetaColumnNames (table $table, [ $numIndexes = false])
  • table $table: table name to query
  • $numIndexes

Redefined in descendants as:
MetaDatabases (line 1947)

return the databases that the driver can connect to.

Some databases will return an empty array.

  • return: array of database names.
an MetaDatabases ()

Redefined in descendants as:
MetaError (line 1028)
void MetaError ([ $err = false])
  • $err
MetaErrorMsg (line 1035)
void MetaErrorMsg ( $errno)
  • $errno
MetaForeignKeys (line 1064)
  • return: array where keys are tables, and values are foreign keys
assoc MetaForeignKeys ( $table, [ $owner = false], [ $upper = false])
  • $table
  • $owner
  • $upper

Redefined in descendants as:
MetaIndexes (line 2098)

List indexes on a table as an array.

  • return: of indexes on current table. Each element represents an index, and is itself an associative array.
array &MetaIndexes (table $table, [primary $primary = false], [ $owner = false])
  • table $table: table name to query
  • primary $primary: true to only show primary keys. Not actually used for most databases
  • $owner

Redefined in descendants as:
MetaPrimaryKeys (line 1044)
  • return: array with the primary key columns in it.
an MetaPrimaryKeys ( $table, [ $owner = false])
  • $table
  • $owner

Redefined in descendants as:
MetaTables (line 1977)
  • return: of tables for current database.
array &MetaTables ([ttype $ttype = false], [showSchema $showSchema = false], [mask $mask = false])
  • ttype $ttype: can either be 'VIEW' or 'TABLE' or false. If false, both views and tables are returned. "VIEW" returns only views "TABLE" returns only tables
  • showSchema $showSchema: returns the schema/user with the table name, eg. USER.TABLE
  • mask $mask: is the input mask - only supported by oci8 and postgresql

Redefined in descendants as:
MetaType (line 1851)
void MetaType ( $t, [ $len = -1], [ $fieldobj = false])
  • $t
  • $len
  • $fieldobj
NConnect (line 451)

Always force a new connection to database - currently only works with oracle

  • return: or false
true NConnect ([[argHostname] $argHostname = ""], [[argUsername] $argUsername = ""], [[argPassword] $argPassword = ""], [[argDatabaseName] $argDatabaseName = ""])
  • [argHostname] $argHostname: Host to connect to
  • [argUsername] $argUsername: Userid to login
  • [argPassword] $argPassword: Associated password
  • [argDatabaseName] $argDatabaseName: database
nextId (line 574)

PEAR DB Compat - do not use internally.

void nextId ( $seq_name)
  • $seq_name
OffsetDate (line 1340)
void OffsetDate ( $dayFraction, [ $date = false])
  • $dayFraction
  • $date

Redefined in descendants as:
outp (line 362)

All error messages go through this bottleneck function.

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

void outp ( $msg, [ $newline = true])
  • $msg
  • $newline
OutParameter (line 677)
void OutParameter ( &$stmt,  &$var,  $name, [ $maxLen = 4000], [ $type = false])
  • &$stmt
  • &$var
  • $name
  • $maxLen
  • $type
PageExecute (line 2363)

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 readme.htm#ex8 for an example of usage.

  • return:

    recordset ($rs->databaseType == 'array')

    NOTE: phpLens uses a different algorithm and does not use PageExecute().

the &PageExecute (sql $sql, nrows $nrows, page $page, [[inputarr] $inputarr = false], [[secs2cache] $secs2cache = 0])
  • sql $sql
  • nrows $nrows: is the number of rows per page to get
  • page $page: is the page number to get (1-based)
  • [inputarr] $inputarr: array of bind variables
  • [secs2cache] $secs2cache: is a private parameter only used by jlim
Param (line 662)
void Param ( $name, [ $type = 'C'])
  • $name
  • $type

Redefined in descendants as:
Parameter (line 698)
void Parameter ( &$stmt,  &$var,  $name, [ $isOutput = false], [ $maxLen = 4000], [ $type = false])
  • &$stmt
  • &$var
  • $name
  • $isOutput
  • $maxLen
  • $type

Redefined in descendants as:
PConnect (line 466)

Establish persistent connect to database

  • return: true or false
return PConnect ([[argHostname] $argHostname = ""], [[argUsername] $argUsername = ""], [[argPassword] $argPassword = ""], [[argDatabaseName] $argDatabaseName = ""])
  • [argHostname] $argHostname: Host to connect to
  • [argUsername] $argUsername: Userid to login
  • [argPassword] $argPassword: Associated password
  • [argDatabaseName] $argDatabaseName: database
PO_Insert_ID (line 983)

Portable Insert ID. Pablo Roca <pabloroca#mvps.org>

  • return: last inserted ID. All databases support this. But aware possible problems in multiuser environments. Heavy test this before deploying.
the PO_Insert_ID ([ $table = ""], [ $id = ""])
  • $table
  • $id
Prepare (line 517)

Should prepare the sql statement and return the stmt 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');

  • return: FALSE, or the prepared statement, or the original sql if if the database does not support prepare.
return Prepare (sql $sql)
  • sql $sql: SQL to send to database

Redefined in descendants as:
PrepareSP (line 536)

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

Should prepare the stored procedure and return the stmt resource. For databases that do not support this, we return the $sql. To ensure compatibility with databases that do not support prepare:

  • return: FALSE, or the prepared statement, or the original sql if if the database does not support prepare.
return PrepareSP (sql $sql, [ $param = true])
  • sql $sql: SQL to send to database
  • $param

Redefined in descendants as:
q (line 557)
void q ( &$s)
  • &$s
QMagic (line 552)
void QMagic ( $s)
  • $s
qstr (line 2322)

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",magic_quotes_runtime());

  • return: string to be sent back to database
quoted qstr (s $s, [[magic_quotes] $magic_quotes = false])
  • s $s: the string to quote
  • [magic_quotes] $magic_quotes: if $s is GET/POST var, set to get_magic_quotes_gpc(). This undoes the stupidity of magic quotes for GPC.

Redefined in descendants as:
Query (line 626)

PEAR DB Compat - do not use internally.

void &Query ( $sql, [ $inputarr = false])
  • $sql
  • $inputarr
Quote (line 544)

PEAR DB Compat

void Quote ( $s)
  • $s
Replace (line 1457)

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 hueristic 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

void Replace ( $table,  $fieldArray,  $keyCol, [ $autoQuote = false], [ $has_autoinc = false])
  • $table
  • $fieldArray
  • $keyCol
  • $autoQuote
  • $has_autoinc
RollbackLock (line 596)
void RollbackLock ( $table)
  • $table
RowLock (line 586)

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

void RowLock ($table $table, $where $where)
  • $table $table: name of table to lock
  • $where $where: where clause to use, eg: "WHERE row=12". If left empty, will escalate to table lock

Redefined in descendants as:
SelectDB (line 1074)

Choose a database to connect to. Many databases do not support this.

  • return: or false
true SelectDB (dbName $dbName)
  • dbName $dbName: is the name of the database to select

Redefined in descendants as:
SelectLimit (line 1097)

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

  • return: recordset ($rs->databaseType == 'array')
the &SelectLimit (sql $sql, [[offset] $nrows = -1], [[nrows] $offset = -1], [[inputarr] $inputarr = false], [[secs2cache] $secs2cache = 0])
  • sql $sql
  • [offset] $nrows: is the row to start calculations from (1-based)
  • [nrows] $offset: is the number of rows to get
  • [inputarr] $inputarr: array of bind variables
  • [secs2cache] $secs2cache: is a private parameter only used by jlim

Redefined in descendants as:
SerializableRS (line 1165)

Create serializable recordset. Breaks rs link to connection.

void &SerializableRS (rs &$rs)
  • rs &$rs: the recordset to serialize
SetCharSet (line 1809)
void SetCharSet ( $charset)
  • $charset

Redefined in descendants as:
SetDateLocale (line 1867)

Change the SQL connection locale to a specified locale.

This is used to get the date formats written depending on the client locale.

void SetDateLocale ([ $locale = 'En'])
  • $locale
SetFetchMode (line 610)

PEAR DB Compat - do not use internally.

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

  • return: previous fetch mode
The SetFetchMode (mode $mode)
  • mode $mode: The fetchmode ADODB_FETCH_ASSOC or ADODB_FETCH_NUM
StartTrans (line 713)
void StartTrans ([ $errfn = 'ADODB_TransMonitor'])
  • $errfn
Time (line 386)
void Time ()

Redefined in descendants as:
UnixDate (line 2193)

Also in ADORecordSet.

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

Redefined in descendants as:
UnixTimeStamp (line 2217)

Also in ADORecordSet.

  • return: in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
date UnixTimeStamp ($v $v)
  • $v $v: is a timestamp string in YYYY-MM-DD HH-NN-SS format

Redefined in descendants as:
UpdateBlob (line 1776)

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');

void UpdateBlob ( $table,  $column,  $val,  $where, [ $blobtype = 'BLOB'])
  • $table
  • $column
  • $val
  • $where
  • $blobtype

Redefined in descendants as:
UpdateBlobFile (line 1790)

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');

void UpdateBlobFile ( $table,  $column,  $path,  $where, [ $blobtype = 'BLOB'])
  • $table
  • $column
  • $path
  • $where
  • $blobtype

Redefined in descendants as:
UpdateClob (line 1844)

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');

void UpdateClob ( $table,  $column,  $val,  $where)
  • $table
  • $column
  • $val
  • $where
UserDate (line 2247)

Also in ADORecordSet.

Format database date based on user defined format.

  • return: date formated as user desires
a UserDate (v $v, [fmt $fmt = 'Y-m-d'], [ $gmt = false])
  • v $v: is the character date in YYYY-MM-DD format, returned by database
  • fmt $fmt: is the format to apply to it, using date()
  • $gmt
UserTimeStamp (line 2268)
  • return: timestamp formated as user desires
a UserTimeStamp (v $v, [fmt $fmt = 'Y-m-d H:i:s'], [ $gmt = false])
  • v $v: is the character timestamp in YYYY-MM-DD hh:mm:ss format
  • fmt $fmt: is the format to apply to it, using date()
  • $gmt
Version (line 329)
void Version ()
_Execute (line 862)
void &_Execute ( $sql, [ $inputarr = false])
  • $sql
  • $inputarr

Redefined in descendants as:
_findschema (line 2021)
void _findschema ( &$table,  &$schema)
  • &$table
  • &$schema
_findvers (line 352)
void _findvers ( $str)
  • $str
_gencachename (line 1546)

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!

void _gencachename ( $sql,  $createdir)
  • $sql
  • $createdir
_nconnect (line 435)
void _nconnect ( $argHostname,  $argUsername,  $argPassword,  $argDatabaseName)
  • $argHostname
  • $argUsername
  • $argPassword
  • $argDatabaseName

Redefined in descendants as:
_rs2rs (line 1184)

Convert database recordset to an array recordset input recordset's cursor should be at beginning, and old $rs will be closed.

  • return: new recordset
the &_rs2rs (rs &$rs, [[nrows] $nrows = -1], [[offset] $offset = -1], [ $close = true])
  • rs &$rs: the recordset to copy
  • [nrows] $nrows: number of rows to retrieve (optional)
  • [offset] $offset: offset by number of rows (optional)
  • $close

Documentation generated on Wed, 23 Jan 2008 19:34:31 -0500 by phpDocumentor 1.4.0