Solutions Open Source

Référence de la classe ADOConnection

Graphe d'héritage de ADOConnection:

Inheritance graph
[légende]

Liste de tous les membres

Fonctions membres publiques

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

Attributs publics

 $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 = ''


Description détaillée

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

Documentation des fonctions membres

ADOConnection::ADOConnection (  ) 

Constructor

ADOConnection::Version (  ) 

ADOConnection::ServerInfo (  ) 

Get server version info...

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

Réimplémentée dans 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, et ADODB_sqlite.

ADOConnection::IsConnected (  ) 

ADOConnection::_findvers ( str  ) 

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.

ADOConnection::Time (  ) 

Réimplémentée dans ADODB_access, ADODB_oci8, ADODB_pdo, et ADODB_vfp.

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

Connect to database

Paramètres:
[argHostname] Host to connect to
[argUsername] Userid to login
[argPassword] Associated password
[argDatabaseName] database
[forceNew] force new connection
Renvoie:
true or false

ADOConnection::_nconnect ( argHostname,
argUsername,
argPassword,
argDatabaseName 
)

Réimplémentée dans ADODB_mysql, ADODB_oci8, et ADODB_postgres64.

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

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

Paramètres:
[argHostname] Host to connect to
[argUsername] Userid to login
[argPassword] Associated password
[argDatabaseName] database
Renvoie:
true or false

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

Establish persistent connect to database

Paramètres:
[argHostname] Host to connect to
[argUsername] Userid to login
[argPassword] Associated password
[argDatabaseName] database
Renvoie:
return true or false

ADOConnection::SQLDate ( fmt,
col = false 
)

Réimplémentée dans ADODB_db2, ADODB_ibase, ADODB_mysql, ADODB_oci8, ADODB_ODBC_DB2, ADODB_odbc_mssql, ADODB_postgres64, ADODB_sqlite, et ADODB_sybase.

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

Paramètres:
sql SQL to send to database
Renvoie:
return FALSE, or the prepared statement, or the original sql if if the database does not support prepare.

Réimplémentée dans ADODB_db2, ADODB_ibase, ADODB_odbc, ADODB_odbtp, et ADODB_pdo.

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:

Paramètres:
sql SQL to send to database
Renvoie:
return FALSE, or the prepared statement, or the original sql if if the database does not support prepare.

ADOConnection::Quote ( s  ) 

PEAR DB Compat

ADOConnection::QMagic ( s  ) 

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

ADOConnection::q ( &$  s  ) 

ADOConnection::ErrorNative (  ) 

PEAR DB Compat - do not use internally.

ADOConnection::nextId ( seq_name  ) 

PEAR DB Compat - do not use internally.

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

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

ADOConnection::CommitLock ( table  ) 

ADOConnection::RollbackLock ( table  ) 

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

Paramètres:
mode The fetchmode ADODB_FETCH_ASSOC or ADODB_FETCH_NUM
Renvoie:
The previous fetch mode

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

PEAR DB Compat - do not use internally.

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

PEAR DB Compat - do not use internally

ADOConnection::Disconnect (  ) 

PEAR DB Compat - do not use internally

ADOConnection::Param ( name,
type = 'C' 
)

Réimplémentée dans ADODB_oci8.

ADOConnection::InParameter ( &$  stmt,
&$  var,
name,
maxLen = 4000,
type = false 
)

Réimplémentée dans ADODB_pdo.

ADOConnection::OutParameter ( &$  stmt,
&$  var,
name,
maxLen = 4000,
type = false 
)

ADOConnection::Parameter ( &$  stmt,
&$  var,
name,
isOutput = false,
maxLen = 4000,
type = false 
)

Réimplémentée dans ADODB_oci8, et ADODB_odbtp.

ADOConnection::IgnoreErrors ( saveErrs = false  ) 

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.

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.

Renvoie:
true on commit, false on rollback.

ADOConnection::FailTrans (  ) 

ADOConnection::HasFailedTrans (  ) 

Check if transaction has failed, only for Smart Transactions.

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

Execute SQL

Paramètres:
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.
Renvoie:
RecordSet or false

Réimplémentée dans ADODB_oci8.

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

Réimplémentée dans ADODB_csv, et ADODB_ibase.

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

Réimplémentée dans ADODB_ado_mssql, ADODB_db2, ADODB_ibase, ADODB_mysql, ADODB_odbc, ADODB_odbtp, et ADODB_sqlite.

ADOConnection::DropSequence ( seqname = 'adodbseq'  ) 

Réimplémentée dans ADODB_db2, ADODB_ibase, ADODB_odbc, ADODB_odbtp, et ADODB_sqlite.

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

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

Paramètres:
seqname name of sequence to use
startID if sequence does not exist, start at this ID
Renvoie:
0 if not supported, otherwise a sequence id

Réimplémentée dans ADODB_ado_mssql, ADODB_db2, ADODB_ibase, ADODB_mysql, ADODB_odbc, ADODB_odbtp, et ADODB_sqlite.

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

Paramètres:
$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 ''
Renvoie:
the last inserted ID. Not all databases support this.

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

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

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

ADOConnection::Affected_Rows (  ) 

Renvoie:
# rows affected by UPDATE/DELETE

ADOConnection::ErrorMsg (  ) 

Renvoie:
the last error message

Réimplémentée dans 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, et ADODB_sybase_ase.

ADOConnection::ErrorNo (  ) 

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

Réimplémentée dans 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, et ADODB_sqlite.

ADOConnection::MetaError ( err = false  ) 

ADOConnection::MetaErrorMsg ( errno  ) 

ADOConnection::MetaPrimaryKeys ( table,
owner = false 
)

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

Réimplémentée dans ADODB_odbtp.

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

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

Réimplémentée dans ADODB_odbc_mssql, ADODB_odbtp, et ADODB_postgres7.

ADOConnection::SelectDB (