Documentation TYPO3 par Ameos

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)
 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)
 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)
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
 $sysDate = false
 cache for 1 hour
 $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
 $_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 232 of file adodb.inc.php.


Constructor & Destructor Documentation

ADOConnection::ADOConnection  ) 
 

Constructor

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


Member Function Documentation

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

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

ADOConnection::_gencachename sql,
createdir
 

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!

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

References outp().

& ADOConnection::_rs2rs &$  rs,
nrows = -1,
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.

Parameters:
rs the recordset to copy
[nrows] number of rows to retrieve (optional)
[offset] offset by number of rows (optional)
Returns:
the new recordset

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

References $false.

Referenced by _Execute(), SelectLimit(), and SerializableRS().

ADOConnection::addq s,
magic_quotes = false
 

Quotes a string, without prefixing nor appending quotes.

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

ADOConnection::Affected_Rows  ) 
 

Returns:
# rows affected by UPDATE/DELETE

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

References outp().

ADOConnection::BeginTrans  ) 
 

Begin a Transaction. Must be followed by CommitTrans() or RollbackTrans().

Returns:
true if succeeded or false if database does not support transactions

Reimplemented in ADODB_access, ADODB_ado, ADODB_ado, ADODB_ado_access, ADODB_borland_ibase, ADODB_db2, ADODB_ibase, ADODB_mysql, ADODB_mysqlt, ADODB_oci8, ADODB_odbc, ADODB_odbtp, ADODB_oracle, ADODB_pdo, ADODB_postgres64, ADODB_sqlite, ADODB_sybase, and ADODB_vfp.

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

Referenced by StartTrans().

& ADOConnection::CacheExecute secs2cache,
sql = false,
inputarr = false
 

Execute SQL, caching recordsets.

Parameters:
[secs2cache] seconds to cache data, set to 0 to force query. This is an optional parameter.
sql SQL statement to execute
[inputarr] holds the input data to bind to
Returns:
RecordSet or false

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

References outp().

Referenced by ADODB_sqlite::SelectLimit(), ADODB_postgres7::SelectLimit(), ADODB_pdo_pgsql::SelectLimit(), ADODB_pdo_mysql::SelectLimit(), ADODB_firebird::SelectLimit(), ADODB_borland_ibase::SelectLimit(), and SelectLimit().

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

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

References outp().

& ADOConnection::CachePageExecute secs2cache,
sql,
nrows,
page,
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.

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

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

& ADOConnection::CacheSelectLimit secs2cache,
sql,
nrows = -1,
offset = -1,
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

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

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

References outp().

ADOConnection::Close  ) 
 

Close Connection

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

Referenced by Disconnect().

ADOConnection::CommitTrans ok = true  ) 
 

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

Parameters:
$ok set to false to rollback transaction, true to commit
Returns:
true/false.

Reimplemented in ADODB_ado, ADODB_ado, ADODB_db2, ADODB_ibase, ADODB_mysqlt, ADODB_oci8, ADODB_odbc, ADODB_odbtp, ADODB_oracle, ADODB_pdo, ADODB_postgres64, ADODB_sqlite, and ADODB_sybase.

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

Referenced by CommitLock(), and CompleteTrans().

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 737 of file adodb.inc.php.

References CommitTrans(), outp(), and RollbackTrans().

ADOConnection::Concat  ) 
 

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

Returns:
concatenated string

Reimplemented in ADODB_fbsql, and ADODB_mysql.

Definition at line 2299 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 403 of file adodb.inc.php.

References _nconnect(), ErrorMsg(), ErrorNo(), and outp().

Referenced by NConnect(), and PConnect().

ADOConnection::DBDate d  ) 
 

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

Parameters:
d a date in Unix date time format.
Returns:
date string in database date format

Reimplemented in ADODB_oci8, and ADODB_oracle.

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

References UnixDate().

Referenced by ADODB_oracle::BindDate(), and ADODB_oci8::BindDate().

ADOConnection::DBTimeStamp ts  ) 
 

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

Parameters:
ts a timestamp in Unix date time format.
Returns:
timestamp string in database timestamp format

Reimplemented in ADODB_oci8, and ADODB_oracle.

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

References UnixTimeStamp().

Referenced by ADODB_oracle::BindTimeStamp(), and ADODB_oci8::BindTimeStamp().

ADOConnection::Disconnect  ) 
 

PEAR DB Compat - do not use internally

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

References Close().

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 1018 of file adodb.inc.php.

Referenced by _Execute(), Connect(), ADODB_odbc::ErrorMsg(), ADODB_db2::ErrorMsg(), and PConnect().

ADOConnection::ErrorNative  ) 
 

PEAR DB Compat - do not use internally.

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

References ErrorNo().

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 1028 of file adodb.inc.php.

Referenced by _Execute(), Connect(), ErrorNative(), ADODB_odbc::ErrorNo(), ADODB_db2::ErrorNo(), MetaError(), and PConnect().

& 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 792 of file adodb.inc.php.

References _Execute(), outp(), Prepare(), and qstr().

Referenced by ADODB_odbc::_connect(), ADODB_db2::_connect(), ADODB_odbc::_pconnect(), ADODB_db2::_pconnect(), ADODB_sybase::BeginTrans(), ADODB_sqlite::BeginTrans(), ADODB_mysqlt::BeginTrans(), ADODB_sybase::CommitTrans(), ADODB_sqlite::CommitTrans(), ADODB_mysqlt::CommitTrans(), ADODB_sqlanywhere::create_blobvar(), ADODB_sqlite::CreateSequence(), ADODB_odbtp::CreateSequence(), ADODB_odbc::CreateSequence(), ADODB_mysql::CreateSequence(), ADODB_ibase::CreateSequence(), ADODB_ado_mssql::CreateSequence(), CreateSequence(), ADODB_sqlanywhere::drop_blobvar(), ADODB_sqlite::DropSequence(), ADODB_odbtp::DropSequence(), ADODB_odbc::DropSequence(), ADODB_ibase::DropSequence(), DropSequence(), ADODB_sqlite::GenID(), ADODB_odbtp::GenID(), ADODB_odbc::GenID(), ADODB_mysql::GenID(), ADODB_ibase::GenID(), ADODB_ado_mssql::GenID(), GenID(), ADODB_sybase_ase::MetaColumns(), ADODB_sqlite::MetaColumns(), ADODB_pdo_pgsql::MetaColumns(), ADODB_pdo_oci::MetaColumns(), ADODB_pdo_mysql::MetaColumns(), ADODB_netezza::MetaColumns(), ADODB_ibase::MetaColumns(), ADODB_fbsql::MetaColumns(), ADODB_sybase_ase::MetaDatabases(), ADODB_postgres7::MetaForeignKeys(), ADODB_sqlite::MetaIndexes(), ADODB_SAPDB::MetaIndexes(), ADODB_mysql::MetaIndexes(), ADODB_ibase::MetaIndexes(), ADODB_sybase_ase::MetaTables(), ADODB_odbc_oracle::MetaTables(), Query(), ADODB_sybase::RollbackTrans(), ADODB_sqlite::RollbackTrans(), ADODB_mysqlt::RollbackTrans(), ADODB_mysqlt::RowLock(), ADODB_ibase::RowLock(), ADODB_sybase::SelectLimit(),