ADOConnection Class Reference

Inheritance diagram for ADOConnection:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 ADOConnection ()
 Version ()
 ServerInfo ()
 IsConnected ()
 _findvers ($str)
 outp ($msg, $newline=true)
 Time ()
 Connect ($argHostname="", $argUsername="", $argPassword="", $argDatabaseName="", $forceNew=false)
 _nconnect ($argHostname, $argUsername, $argPassword, $argDatabaseName)
 NConnect ($argHostname="", $argUsername="", $argPassword="", $argDatabaseName="")
 PConnect ($argHostname="", $argUsername="", $argPassword="", $argDatabaseName="")
 SQLDate ($fmt, $col=false)
 Prepare ($sql)
 PrepareSP ($sql, $param=true)
 Quote ($s)
 QMagic ($s)
 q (&$s)
 ErrorNative ()
 nextId ($seq_name)
 RowLock ($table, $where)
 CommitLock ($table)
 RollbackLock ($table)
 SetFetchMode ($mode)
Query ($sql, $inputarr=false)
LimitQuery ($sql, $offset, $count, $params=false)
 Disconnect ()
 Param ($name, $type='C')
 InParameter (&$stmt, &$var, $name, $maxLen=4000, $type=false)
 OutParameter (&$stmt, &$var, $name, $maxLen=4000, $type=false)
 Parameter (&$stmt, &$var, $name, $isOutput=false, $maxLen=4000, $type=false)
 IgnoreErrors ($saveErrs=false)
 StartTrans ($errfn= 'ADODB_TransMonitor')
 CompleteTrans ($autoComplete=true)
 FailTrans ()
 HasFailedTrans ()
Execute ($sql, $inputarr=false)
_Execute ($sql, $inputarr=false)
 CreateSequence ($seqname='adodbseq', $startID=1)
 DropSequence ($seqname='adodbseq')
 GenID ($seqname='adodbseq', $startID=1)
 Insert_ID ($table='', $column='')
 PO_Insert_ID ($table="", $id="")
 Affected_Rows ()
 ErrorMsg ()
 ErrorNo ()
 MetaError ($err=false)
 MetaErrorMsg ($errno)
 MetaPrimaryKeys ($table, $owner=false)
 MetaForeignKeys ($table, $owner=false, $upper=false)
 SelectDB ($dbName)
SelectLimit ($sql, $nrows=-1, $offset=-1, $inputarr=false, $secs2cache=0)
SerializableRS (&$rs)
_rs2rs (&$rs, $nrows=-1, $offset=-1, $close=true)
GetAll ($sql, $inputarr=false)
GetAssoc ($sql, $inputarr=false, $force_array=false, $first2cols=false)
CacheGetAssoc ($secs2cache, $sql=false, $inputarr=false, $force_array=false, $first2cols=false)
 GetOne ($sql, $inputarr=false)
 CacheGetOne ($secs2cache, $sql=false, $inputarr=false)
 GetCol ($sql, $inputarr=false, $trim=false)
 CacheGetCol ($secs, $sql=false, $inputarr=false, $trim=false)
Transpose (&$rs, $addfieldnames=true)
 OffsetDate ($dayFraction, $date=false)
GetArray ($sql, $inputarr=false)
CacheGetAll ($secs2cache, $sql=false, $inputarr=false)
CacheGetArray ($secs2cache, $sql=false, $inputarr=false)
GetRow ($sql, $inputarr=false)
CacheGetRow ($secs2cache, $sql=false, $inputarr=false)
 Replace ($table, $fieldArray, $keyCol, $autoQuote=false, $has_autoinc=false)
CacheSelectLimit ($secs2cache, $sql, $nrows=-1, $offset=-1, $inputarr=false)
 CacheFlush ($sql=false, $inputarr=false)
 _dirFlush ($dir, $kill_top_level=false)
 xCacheFlush ($sql=false, $inputarr=false)
 _gencachename ($sql, $createdir, $memcache=false)
CacheExecute ($secs2cache, $sql=false, $inputarr=false)
AutoExecute ($table, $fields_values, $mode= 'INSERT', $where=FALSE, $forceUpdate=true, $magicq=false)
 GetUpdateSQL (&$rs, $arrFields, $forceUpdate=false, $magicq=false, $force=null)
 GetInsertSQL (&$rs, $arrFields, $magicq=false, $force=null)
 UpdateBlob ($table, $column, $val, $where, $blobtype='BLOB')
 UpdateBlobFile ($table, $column, $path, $where, $blobtype='BLOB')
 BlobDecode ($blob)
 BlobEncode ($blob)
 SetCharSet ($charset)
 IfNull ($field, $ifNull)
 LogSQL ($enable=true)
 GetCharSet ()
 UpdateClob ($table, $column, $val, $where)
 MetaType ($t, $len=-1, $fieldobj=false)
 SetDateLocale ($locale= 'En')
GetActiveRecordsClass ($class, $table, $whereOrderBy=false, $bindarr=false, $primkeyArr=false)
GetActiveRecords ($table, $where=false, $bindarr=false, $primkeyArr=false)
 Close ()
 BeginTrans ()
 SetTransactionMode ($transaction_mode)
 MetaTransaction ($mode, $db)
 CommitTrans ($ok=true)
 RollbackTrans ()
 MetaDatabases ()
MetaTables ($ttype=false, $showSchema=false, $mask=false)
 _findschema (&$table, &$schema)
MetaColumns ($table, $normalize=true)
MetaIndexes ($table, $primary=false, $owner=false)
MetaColumnNames ($table, $numIndexes=false, $useattnum=false)
 Concat ()
 DBDate ($d)
 BindDate ($d)
 BindTimeStamp ($d)
 DBTimeStamp ($ts)
 UnixDate ($v)
 UnixTimeStamp ($v)
 UserDate ($v, $fmt='Y-m-d', $gmt=false)
 UserTimeStamp ($v, $fmt='Y-m-d H:i:s', $gmt=false)
 escape ($s, $magic_quotes=false)
 addq ($s, $magic_quotes=false)
 qstr ($s, $magic_quotes=false)
PageExecute ($sql, $nrows, $page, $inputarr=false, $secs2cache=0)
CachePageExecute ($secs2cache, $sql, $nrows, $page, $inputarr=false)

Public Attributes

 $dataProvider = 'native'
 $databaseType = ''
 $database = ''
 RDBMS currently in use, eg. odbc, mysql, mssql.
 $host = ''
 Name of database to be used.
 $user = ''
 The hostname of the database server.
 $password = ''
 The username which is used to connect to the database server.
 $debug = false
 Password for the username. For security, we no longer store it.
 $maxblobsize = 262144
 if set to true will output sql statements
 $concat_operator = '+'
 maximum size of blobs or large text fields (262144 = 256K)-- some db's die otherwise like foxpro
 $substr = 'substr'
 default concat operator -- change to || for Oracle/Interbase
 $length = 'length'
 substring operator
 $random = 'rand()'
 string length ofperator
 $upperCase = 'upper'
 random function
 $fmtDate = "'Y-m-d'"
 uppercase function
 $fmtTimeStamp = "'Y-m-d, h:i:s A'"
 used by DBDate() as the default date format used by the database
 $true = '1'
 used by DBTimeStamp as the default timestamp fmt.
 $false = '0'
 string that represents TRUE for a database
 $replaceQuote = "\\'"
 string that represents FALSE for a database
 $nameQuote = '"'
 string to use to replace quotes
 $charSet = false
 string to use to quote identifiers and names
 $metaDatabasesSQL = ''
 character set to use - only for interbase, postgres and oci8
 $metaTablesSQL = ''
 $uniqueOrderBy = false
 $emptyDate = ' '
 All order by columns have to be unique.
 $emptyTimeStamp = ' '
 $lastInsID = false
 $hasInsertID = false
 $hasAffectedRows = false
 supports autoincrement ID?
 $hasTop = false
 supports affected rows for update/delete?
 $hasLimit = false
 support mssql/access SELECT TOP 10 * FROM TABLE
 $readOnly = false
 support pgsql/mysql SELECT * FROM TABLE LIMIT 10
 $hasMoveFirst = false
 this is a readonly database - used by phpLens
 $hasGenID = false
 has ability to run MoveFirst(), scrolling backwards
 $hasTransactions = true
 can generate sequences using GenID();
 $genID = 0
 has transactions
 $raiseErrorFn = false
 sequence id used by GenID();
 $isoDates = false
 error function to call
 $cacheSecs = 3600
 accepts dates in ISO format
 $memCache = false
 cache for 1 hour
 $memCacheHost
 should we use memCache instead of caching in files
 $memCachePort = 11211
 memCache host
 $memCacheCompress = false
 memCache port
 $sysDate = false
 Use 'true' to store the item compressed (uses zlib).
 $sysTimeStamp = false
 name of function that returns the current date
 $arrayClass = 'ADORecordSet_array'
 name of function that returns the current timestamp
 $noNullStrings = false
 name of class used to generate array recordsets, which are pre-downloaded recordsets
 $numCacheHits = 0
 oracle specific stuff - if true ensures that '' is converted to ' '
 $numCacheMisses = 0
 $pageExecuteCountRows = true
 $uniqueSort = false
 $leftOuter = false
 indicates that all fields in order by must be unique
 $rightOuter = false
 operator to use for left outer join in WHERE clause
 $ansiOuter = false
 operator to use for right outer join in WHERE clause
 $autoRollback = false
 whether ansi outer join syntax supported
 $poorAffectedRows = false
 $fnExecute = false
 $fnCacheExecute = false
 $blobEncodeType = false
 $rsPrefix = "ADORecordSet_"
 $autoCommit = true
 $transOff = 0
 do not modify this yourself - actually private
 $transCnt = 0
 temporarily disable transactions
 $fetchMode = false
 count of nested transactions
 $null2null = 'null'
 $_oldRaiseFn = false
 $_transOK = null
 $_connectionID = false
 $_errorMsg = false
 The returned link identifier whenever a successful database connection is made.
 $_errorCode = false
 then returned by the errorMsg() function
 $_queryID = false
 Last error code, not guaranteed to be used - only by oci8.
 $_isPersistentConnection = false
 This variable keeps the last created result link identifier.
 $_bindInputArray = false
 A boolean variable to state whether its a persistent connection or normal connection. */.
 $_evalAll = false
 set to true if ADOConnection.Execute() permits binding of array parameters.
 $_affected = false
 $_logsql = false
 $_transmode = ''


Detailed Description

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

Definition at line 237 of file adodb.inc.php.


Member Function Documentation

ADOConnection::ADOConnection (  ) 

Constructor

Definition at line 338 of file adodb.inc.php.

ADOConnection::ServerInfo (  ) 

Get server version info...

Returns:
An array with 2 elements: $arr['string'] is the description string, and $arr[version] is the version (also a string).

Reimplemented in ADODB_ado, ADODB_ado, ADODB_borland_ibase, ADODB_db2, ADODB_firebird, ADODB_ibase, ADODB_ldap, ADODB_mysql, ADODB_oci8, ADODB_odbc, ADODB_ODBC_DB2, ADODB_odbc_mssql, ADODB_odbtp, ADODB_pdo_base, ADODB_pdo, ADODB_pdo_mssql, ADODB_pdo_mysql, ADODB_pdo_pgsql, ADODB_postgres64, ADODB_SAPDB, and ADODB_sqlite.

Definition at line 356 of file adodb.inc.php.

ADOConnection::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.

Definition at line 376 of file adodb.inc.php.

ADOConnection::Connect ( argHostname = "",
argUsername = "",
argPassword = "",
argDatabaseName = "",
forceNew = false 
)

Connect to database

Parameters:
[argHostname] Host to connect to
[argUsername] Userid to login
[argPassword] Associated password
[argDatabaseName] database
[forceNew] force new connection
Returns:
true or false

Definition at line 419 of file adodb.inc.php.

ADOConnection::NConnect ( argHostname = "",
argUsername = "",
argPassword = "",
argDatabaseName = "" 
)

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

Parameters:
[argHostname] Host to connect to
[argUsername] Userid to login
[argPassword] Associated password
[argDatabaseName] database
Returns:
true or false

Definition at line 465 of file adodb.inc.php.

ADOConnection::PConnect ( argHostname = "",
argUsername = "",
argPassword = "",
argDatabaseName = "" 
)

Establish persistent connect to database

Parameters:
[argHostname] Host to connect to
[argUsername] Userid to login
[argPassword] Associated password
[argDatabaseName] database
Returns:
return true or false

Definition at line 480 of file adodb.inc.php.

ADOConnection::Prepare ( sql  ) 

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

Parameters:
sql SQL to send to database
Returns:
return FALSE, or the prepared statement, or the original sql if if the database does not support prepare.

Reimplemented in ADODB_db2, ADODB_ibase, ADODB_odbc, ADODB_odbtp, and ADODB_pdo.

Definition at line 531 of file adodb.inc.php.

ADOConnection::PrepareSP ( 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:

Parameters:
sql SQL to send to database
Returns:
return FALSE, or the prepared statement, or the original sql if if the database does not support prepare.

Definition at line 550 of file adodb.inc.php.

ADOConnection::Quote ( s  ) 

PEAR DB Compat

Definition at line 558 of file adodb.inc.php.

ADOConnection::QMagic ( s  ) 

Requested by "Karsten Dambekalns" <k.dambekalns@fishfarm.de>

Definition at line 566 of file adodb.inc.php.

ADOConnection::ErrorNative (  ) 

PEAR DB Compat - do not use internally.

Definition at line 580 of file adodb.inc.php.

ADOConnection::nextId ( seq_name  ) 

PEAR DB Compat - do not use internally.

Definition at line 589 of file adodb.inc.php.

ADOConnection::RowLock ( table,
where 
)

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

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

Definition at line 601 of file adodb.inc.php.

ADOConnection::SetFetchMode ( 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 :-)

Parameters:
mode The fetchmode ADODB_FETCH_ASSOC or ADODB_FETCH_NUM
Returns:
The previous fetch mode

Definition at line 625 of file adodb.inc.php.

& ADOConnection::Query ( sql,
inputarr = false 
)

PEAR DB Compat - do not use internally.

Definition at line 641 of file adodb.inc.php.

& ADOConnection::LimitQuery ( sql,
offset,
count,
params = false 
)

PEAR DB Compat - do not use internally

Definition at line 652 of file adodb.inc.php.

ADOConnection::Disconnect (  ) 

PEAR DB Compat - do not use internally

Definition at line 663 of file adodb.inc.php.

ADOConnection::StartTrans ( errfn = 'ADODB_TransMonitor'  ) 

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.
b. CompleteTrans auto-detects SQL errors, and will rollback on errors, commit otherwise.
c. All BeginTrans/CommitTrans/RollbackTrans inside a StartTrans/CompleteTrans block are disabled, making it backward compatible.

Definition at line 742 of file adodb.inc.php.

ADOConnection::CompleteTrans ( autoComplete = true  ) 

Used together with StartTrans() to end a transaction. Monitors connection for sql errors, and will commit or rollback as appropriate.

if true, monitor sql errors and commit and rollback as appropriate, and if set to false force rollback even if no SQL error detected.

Returns:
true on commit, false on rollback.

Definition at line 767 of file adodb.inc.php.

ADOConnection::HasFailedTrans (  ) 

Check if transaction has failed, only for Smart Transactions.

Definition at line 809 of file adodb.inc.php.

& ADOConnection::Execute ( sql,
inputarr = false 
)

Execute SQL

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

Reimplemented in ADODB_oci8.

Definition at line 822 of file adodb.inc.php.

ADOConnection::GenID ( seqname = 'adodbseq',
startID = 1 
)

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

Parameters:
seqname name of sequence to use
startID if sequence does not exist, start at this ID
Returns:
0 if not supported, otherwise a sequence id

Reimplemented in ADODB_ado_mssql, ADODB_db2, ADODB_ibase, ADODB_mysql, ADODB_odbc, ADODB_odbtp, and ADODB_sqlite.

Definition at line 967 of file adodb.inc.php.

ADOConnection::Insert_ID ( table = '',
column = '' 
)

Parameters:
$table string name of the table, not needed by all databases (eg. mysql), default ''
$column string name of the column, not needed by all databases (eg. mysql), default ''
Returns:
the last inserted ID. Not all databases support this.

Definition at line 1000 of file adodb.inc.php.

ADOConnection::PO_Insert_ID ( table = "",
id = "" 
)

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

Returns:
the last inserted ID. All databases support this. But aware possible problems in multiuser environments. Heavy test this before deploying.

Definition at line 1018 of file adodb.inc.php.

ADOConnection::Affected_Rows (  ) 

Returns:
# rows affected by UPDATE/DELETE

Definition at line 1030 of file adodb.inc.php.

ADOConnection::ErrorMsg (  ) 

Returns:
the last error message

Reimplemented in ADODB_ado, ADODB_ado, ADODB_csv, ADODB_db2, ADODB_fbsql, ADODB_ibase, ADODB_mysql, ADODB_oci8, ADODB_odbc, ADODB_odbtp, ADODB_oracle, ADODB_pdo, ADODB_postgres64, ADODB_sqlite, ADODB_sybase, and ADODB_sybase_ase.

Definition at line 1048 of file adodb.inc.php.

ADOConnection::ErrorNo (  ) 

Returns:
the last error number. Normally 0 means no error.

Reimplemented in ADODB_ado, ADODB_ado, ADODB_csv, ADODB_db2, ADODB_fbsql, ADODB_ibase, ADODB_mysql, ADODB_oci8, ADODB_odbc, ADODB_odbtp, ADODB_oracle, ADODB_pdo, ADODB_postgres64, and ADODB_sqlite.

Definition at line 1058 of file adodb.inc.php.

ADOConnection::MetaPrimaryKeys ( table,
owner = false 
)

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

Reimplemented in ADODB_odbtp.

Definition at line 1079 of file adodb.inc.php.

ADOConnection::MetaForeignKeys ( table,
owner = false,
upper = false 
)

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

Reimplemented in ADODB_odbc_mssql, ADODB_odbtp, and ADODB_postgres7.

Definition at line 1099 of file adodb.inc.php.

ADOConnection::SelectDB ( dbName  ) 

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

Parameters:
dbName is the name of the database to select
Returns:
true or false

Reimplemented in ADODB_fbsql, ADODB_ibase, ADODB_ldap, ADODB_mysql, ADODB_oci8, ADODB_odbtp, and ADODB_sybase.

Definition at line 1109 of file adodb.inc.php.

& ADOConnection::SelectLimit (