Class: ADOConnection
Source Location: /includes/classes/adodb/adodb.inc.php
Connection object. For connecting to databases, and executing queries.
|
|
|
Class Details
Class Variables
Class Methods
constructor ADOConnection [line 338]
ADOConnection ADOConnection(
)
|
|
Constructor
method addq [line 2573]
void addq(
$s, [
$magic_quotes = false])
|
|
Quotes a string, without prefixing nor appending quotes.
Parameters:
method Affected_Rows [line 1032]
method AutoExecute [line 1839]
void &AutoExecute(
$table,
$fields_values, [
$mode = 'INSERT'], [
$where = FALSE], [
$forceUpdate = true], [
$magicq = false])
|
|
Parameters:
method BeginTrans [line 2126]
method BindDate [line 2433]
method BindTimeStamp [line 2441]
method BlobDecode [line 1964]
method BlobEncode [line 1969]
method CacheExecute [line 1720]
RecordSet &CacheExecute(
[secs2cache]
$secs2cache, [sql
$sql = false], [[inputarr]
$inputarr = false])
|
|
Execute SQL, caching recordsets.
Tags:
Parameters:
method CacheFlush [line 1571]
void CacheFlush(
[
$sql = false], [
$inputarr = false])
|
|
Flush cached recordsets that match a particular $sql statement. If $sql == false, then we purge all files in the cache.
Parameters:
method CacheGetAll [line 1426]
void &CacheGetAll(
$secs2cache, [
$sql = false], [
$inputarr = false])
|
|
Parameters:
method CacheGetArray [line 1432]
void &CacheGetArray(
$secs2cache, [
$sql = false], [
$inputarr = false])
|
|
Parameters:
method CacheGetAssoc [line 1277]
void &CacheGetAssoc(
$secs2cache, [
$sql = false], [
$inputarr = false], [
$force_array = false], [
$first2cols = false])
|
|
Parameters:
method CacheGetCol [line 1353]
void CacheGetCol(
$secs, [
$sql = false], [
$inputarr = false], [
$trim = false])
|
|
Parameters:
method CacheGetOne [line 1317]
void CacheGetOne(
$secs2cache, [
$sql = false], [
$inputarr = false])
|
|
Parameters:
method CacheGetRow [line 1487]
void &CacheGetRow(
$secs2cache, [
$sql = false], [
$inputarr = false])
|
|
Parameters:
method CachePageExecute [line 2670]
the &CachePageExecute(
secs2cache
$secs2cache, sql
$sql, nrows
$nrows, page
$page, [[inputarr]
$inputarr = false])
|
|
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.
Tags:
Parameters:
method CacheSelectLimit [line 1547]
the &CacheSelectLimit(
[secs2cache]
$secs2cache, sql
$sql, [[offset]
$nrows = -1], [[nrows]
$offset = -1], [[inputarr]
$inputarr = false])
|
|
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
Tags:
Parameters:
method Close [line 2114]
method CommitLock [line 606]
method CommitTrans [line 2191]
method CompleteTrans [line 767]
void CompleteTrans(
[
$autoComplete = true])
|
|
Parameters:
method Concat [line 2406]
method Connect [line 419]
true Connect(
[[argHostname]
$argHostname = ""], [[argUsername]
$argUsername = ""], [[argPassword]
$argPassword = ""], [[argDatabaseName]
$argDatabaseName = ""], [[forceNew]
$forceNew = false])
|
|
Connect to database
Tags:
Parameters:
method CreateSequence [line 949]
method DBDate [line 2420]
method DBTimeStamp [line 2457]
method Disconnect [line 663]
PEAR DB Compat - do not use internally
method DropSequence [line 955]
method ErrorMsg [line 1050]
method ErrorNative [line 580]
PEAR DB Compat - do not use internally.
method ErrorNo [line 1060]
method escape [line 2565]
void escape(
$s, [
$magic_quotes = false])
|
|
Parameters:
method Execute [line 822]
RecordSet &Execute(
sql
$sql, [[inputarr]
$inputarr = false])
|
|
Execute SQL
Tags:
Overridden in child classes as:
- ADODB_oci8::Execute()
- Execute SQL
Parameters:
method FailTrans [line 794]
method GenID [line 969]
method GetActiveRecords [line 2105]
void &GetActiveRecords(
$table, [
$where = false], [
$bindarr = false], [
$primkeyArr = false])
|
|
Parameters:
method GetActiveRecordsClass [line 2068]
void &GetActiveRecordsClass(
$class,
$table, [
$whereOrderBy = false], [
$bindarr = false], [
$primkeyArr = false])
|
|
Parameters:
method GetAll [line 1260]
void &GetAll(
$sql, [
$inputarr = false])
|
|
Parameters:
method GetArray [line 1405]
void &GetArray(
sql
$sql, [[inputarr]
$inputarr = false])
|
|
Parameters:
method GetAssoc [line 1266]
void &GetAssoc(
$sql, [
$inputarr = false], [
$force_array = false], [
$first2cols = false])
|
|
Parameters:
method GetCharSet [line 1997]
method GetCol [line 1330]
void GetCol(
$sql, [
$inputarr = false], [
$trim = false])
|
|
Parameters:
method GetInsertSQL [line 1909]
void GetInsertSQL(
&$rs,
$arrFields, [
$magicq = false], [
$force = null])
|
|
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.
Parameters:
method GetOne [line 1299]
void GetOne(
sql
$sql, [[inputarr]
$inputarr = false])
|
|
Return first element of first row of sql statement. Recordset is disposed for you.
Overridden in child classes as:
- ADODB_mysql::GetOne()
- ADODB_mysqli::GetOne()
Parameters:
method GetRandRow [line 1454]
method GetRow [line 1467]
void &GetRow(
sql
$sql, [[inputarr]
$inputarr = false])
|
|
Return one row of sql statement. Recordset is disposed for you.
Parameters:
method GetUpdateSQL [line 1884]
void GetUpdateSQL(
&$rs,
$arrFields, [
$forceUpdate = false], [
$magicq = false], [
$force = null])
|
|
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>
Parameters:
method HasFailedTrans [line 809]
method IfNull [line 1979]
method IgnoreErrors [line 720]
void IgnoreErrors(
[
$saveErrs = false])
|
|
Parameters:
method InParameter [line 685]
void InParameter(
&$stmt,
&$var,
$name, [
$maxLen = 4000], [
$type = false])
|
|
Overridden in child classes as:
- ADODB_pdo::InParameter()
Parameters:
method Insert_ID [line 1002]
the Insert_ID(
[$table
$table = ''], [$column
$column = ''])
|
|
Tags:
Parameters:
method IsConnected [line 361]
method LimitQuery [line 652]
void &LimitQuery(
$sql,
$offset,
$count, [
$params = false])
|
|
PEAR DB Compat - do not use internally
Parameters:
method LogSQL [line 1984]
void LogSQL(
[
$enable = true])
|
|
Parameters:
method MetaColumnNames [line 2374]
array &MetaColumnNames(
table
$table, [
$numIndexes = false], [
$useattnum = false])
|
|
List columns names in a table as an array.
Tags:
Overridden in child classes as:
- ADODB_SAPDB::MetaColumnNames()
Parameters:
method MetaColumns [line 2303]
method MetaDatabases [line 2210]
method MetaError [line 1065]
void MetaError(
[
$err = false])
|
|
Parameters:
method MetaErrorMsg [line 1072]
void MetaErrorMsg(
$errno)
|
|
Parameters:
method MetaForeignKeys [line 1101]
method MetaIndexes [line 2362]
method MetaPrimaryKeys [line 1081]
method MetaTables [line 2241]
method MetaTransaction [line 2144]
void MetaTransaction(
$mode,
$db)
|
|
Parameters:
method MetaType [line 2016]
void MetaType(
$t, [
$len = -1], [
$fieldobj = false])
|
|
Parameters:
method NConnect [line 465]
true NConnect(
[[argHostname]
$argHostname = ""], [[argUsername]
$argUsername = ""], [[argPassword]
$argPassword = ""], [[argDatabaseName]
$argDatabaseName = ""])
|
|
Always force a new connection to database - currently only works with oracle
Tags:
Parameters:
method nextId [line 589]
PEAR DB Compat - do not use internally.
Parameters:
method OffsetDate [line 1393]
method outp [line 376]
void outp(
$msg, [
$newline = true])
|
|
All error messages go through this bottleneck function. You can define your own handler by defining the function name in ADODB_OUTP.
Parameters:
method OutParameter [line 692]
void OutParameter(
&$stmt,
&$var,
$name, [
$maxLen = 4000], [
$type = false])
|
|
Parameters:
method PageExecute [line 2648]
the &PageExecute(
sql
$sql, nrows
$nrows, page
$page, [[inputarr]
$inputarr = false], [[secs2cache]
$secs2cache = 0])
|
|
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.
Tags:
Parameters:
method Param [line 677]
method Parameter [line 714]
method PConnect [line 480]
return PConnect(
[[argHostname]
$argHostname = ""], [[argUsername]
$argUsername = ""], [[argPassword]
$argPassword = ""], [[argDatabaseName]
$argDatabaseName = ""])
|
|
Establish persistent connect to database
Tags:
Parameters:
method PO_Insert_ID [line 1020]
the PO_Insert_ID(
[
$table = ""], [
$id = ""])
|
|
Portable Insert ID. Pablo Roca <pabloroca#mvps.org>
Tags:
Parameters:
method Prepare [line 531]
method PrepareSP [line 550]
return PrepareSP(
sql
$sql, [
$param = true])
|
|
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:
Tags:
Overridden in child classes as:
- ADODB_mssql::PrepareSP()
- ADODB_mssqlpo::PrepareSP()
- ADODB_odbtp::PrepareSP()
Parameters:
method q [line 571]
method QMagic [line 566]
method qstr [line 2607]
method Query [line 641]
void &Query(
$sql, [
$inputarr = false])
|
|
PEAR DB Compat - do not use internally.
Parameters:
method Quote [line 558]
PEAR DB Compat
Parameters:
method Replace [line 1520]
void Replace(
$table,
$fieldArray,
$keyCol, [
$autoQuote = false], [
$has_autoinc = false])
|
|
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
Parameters:
method RollbackLock [line 611]
void RollbackLock(
$table)
|
|
Parameters:
method RollbackTrans [line 2200]
method RowLock [line 601]
method SelectDB [line 1111]
method SelectLimit [line 1134]
the &SelectLimit(
sql
$sql, [[offset]
$nrows = -1], [[nrows]
$offset = -1], [[inputarr]
$inputarr = false], [[secs2cache]
$secs2cache = 0])
|
|
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
Tags:
Overridden in child classes as:
- ADODB_csv::SelectLimit()
- ADODB_borland_ibase::SelectLimit()
- ADODB_firebird::SelectLimit()
- ADODB_mssql::SelectLimit()
- ADODB_mysql::SelectLimit()
- ADODB_mysqli::SelectLimit()
- ADODB_oci8::SelectLimit()
- ADODB_oci805::SelectLimit()
- ADODB_ODBC_DB2::SelectLimit()
- ADODB_odbc_mssql::SelectLimit()
- ADODB_vfp::SelectLimit()
- ADODB_odbtp::SelectLimit()
- ADODB_pdo::SelectLimit()
- ADODB_pdo_base::SelectLimit()
- ADODB_pdo_mssql::SelectLimit()
- ADODB_pdo_mysql::SelectLimit()
- ADODB_pdo_pgsql::SelectLimit()
- ADODB_postgres7::SelectLimit()
- ADODB_sqlite::SelectLimit()
- ADODB_sybase::SelectLimit()
Parameters:
method SerializableRS [line 1202]
void &SerializableRS(
rs
&$rs)
|
|
Create serializable recordset. Breaks rs link to connection.
Parameters:
method ServerInfo [line 356]
method SetCharSet [line 1974]
method SetDateLocale [line 2032]
void SetDateLocale(
[
$locale = 'En'])
|
|
Change the SQL connection locale to a specified locale. This is used to get the date formats written depending on the client locale.
Parameters:
method SetFetchMode [line 625]
The SetFetchMode(
mode
$mode)
|
|
PEAR DB Compat - do not use internally. The fetch modes for NUMERIC and ASSOC for PEAR DB and ADODB are identical for easy porting :-)
Tags:
Parameters:
method SetTransactionMode [line 2133]
method SQLDate [line 510]
method StartTrans [line 742]
void StartTrans(
[
$errfn = 'ADODB_TransMonitor'])
|
|
Parameters:
method Time [line 400]
method Transpose [line 1376]
void &Transpose(
&$rs, [
$addfieldnames = true])
|
|
Parameters:
method UnixDate [line 2478]
method UnixTimeStamp [line 2502]
method UpdateBlob [line 1941]
void UpdateBlob(
$table,
$column,
$val,
$where, [
$blobtype = 'BLOB'])
|
|
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');
Overridden in child classes as:
- ADODB_db2::UpdateBlob()
- ADODB_ibase::UpdateBlob()
- ADODB_informix72::UpdateBlob()
- ADODB_mssql::UpdateBlob()
- ADODB_oci8::UpdateBlob()
- Usage: Store BLOBs and CLOBs
- ADODB_odbc::UpdateBlob()
- ADODB_sqlanywhere::UpdateBlob()
- ADODB_odbtp::UpdateBlob()
- ADODB_postgres64::UpdateBlob()
Parameters:
method UpdateBlobFile [line 1955]
void UpdateBlobFile(
$table,
$column,
$path,
$where, [
$blobtype = 'BLOB'])
|
|
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');
Overridden in child classes as:
- ADODB_ibase::UpdateBlobFile()
- ADODB_oci8::UpdateBlobFile()
- Usage: store file pointed to by $var in a blob
- ADODB_postgres64::UpdateBlobFile()
Parameters:
method UpdateClob [line 2009]
void UpdateClob(
$table,
$column,
$val,
$where)
|
|
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');
Parameters:
method UserDate [line 2532]
a UserDate(
v
$v, [fmt
$fmt = 'Y-m-d'], [
$gmt = false])
|
|
Also in ADORecordSet. Format database date based on user defined format.
Tags:
Parameters:
method UserTimeStamp [line 2553]
a UserTimeStamp(
v
$v, [fmt
$fmt = 'Y-m-d H:i:s'], [
$gmt = false])
|
|
Tags:
Parameters:
method Version [line 343]
method xCacheFlush [line 1631]
void xCacheFlush(
[
$sql = false], [
$inputarr = false])
|
|
Parameters:
method _dirFlush [line 1615]
void _dirFlush(
$dir, [
$kill_top_level = false])
|
|
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.
Parameters:
method _Execute [line 898]
method _findschema [line 2285]
void _findschema(
&$table,
&$schema)
|
|
Parameters:
method _findvers [line 366]
method _gencachename [line 1684]
void _gencachename(
$sql,
$createdir, [
$memcache = false])
|
|
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!
Parameters:
method _nconnect [line 449]
method _rs2rs [line 1221]
the &_rs2rs(
rs
&$rs, [[nrows]
$nrows = -1], [[offset]
$offset = -1], [
$close = true])
|
|
Convert database recordset to an array recordset input recordset's cursor should be at beginning, and old $rs will be closed.
Tags:
Parameters:
|
|