Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
|
Public Member Functions | |
_close () | |
_connect ($argHostname, $argUsername, $argPassword, $argDatabasename, $mode=0) | |
_CreateCache () | |
Create cache class. | |
_Execute ($sql, $inputarr=false) | |
_findschema (&$table, &$schema) | |
_findvers ($str) | |
Find version string. | |
_gencachename ($sql, $createdir) | |
Private function to generate filename for caching. | |
_nconnect ($argHostname, $argUsername, $argPassword, $argDatabaseName) | |
Always force a new connection to database. | |
_pconnect ($argHostname, $argUsername, $argPassword, $argDatabasename) | |
_query ($sql, $inputarr=false) | |
& | _rs2rs (&$rs, $nrows=-1, $offset=-1, $close=true) |
Convert a database recordset to an array recordset. | |
addQ ($s, $magic_quotes=false) | |
Quotes a string, without prefixing nor appending quotes. | |
Affected_Rows () | |
AutoExecute ($table, $fields_values, $mode='INSERT', $where=false, $forceUpdate=true, $magic_quotes=false) | |
Similar to PEAR DB's autoExecute(), except that $mode can be 'INSERT' or 'UPDATE' or DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE. | |
BeginTrans () | |
Begin a Transaction. | |
BindDate ($d) | |
BindTimeStamp ($d) | |
BlobDecode ($blob) | |
BlobEncode ($blob) | |
CacheExecute ($secs2cache, $sql=false, $inputarr=false) | |
Execute SQL, caching recordsets. | |
CacheFlush ($sql=false, $inputarr=false) | |
Flush cached recordsets that match a particular $sql statement. | |
CacheGetAll ($secs2cache, $sql=false, $inputarr=false) | |
CacheGetArray ($secs2cache, $sql=false, $inputarr=false) | |
CacheGetAssoc ($secs2cache, $sql=false, $inputarr=false, $force_array=false, $first2cols=false) | |
Search for the results of an executed query in the cache. | |
CacheGetCol ($secs, $sql=false, $inputarr=false, $trim=false) | |
CacheGetOne ($secs2cache, $sql=false, $inputarr=false) | |
CacheGetRow ($secs2cache, $sql=false, $inputarr=false) | |
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. | |
CacheSelectLimit ($secs2cache, $sql, $nrows=-1, $offset=-1, $inputarr=false) | |
Will select, getting rows from $offset (1-based), for $nrows. | |
charMax () | |
Returns the maximum size of a MetaType C field. | |
Close () | |
Close Connection. | |
CommitLock ($table) | |
CommitTrans ($ok=true) | |
Commits a transaction. | |
CompleteTrans ($autoComplete=true) | |
Complete a transation. | |
Concat () | |
Concatenate strings. | |
Connect ($argHostname="", $argUsername="", $argPassword="", $argDatabaseName="", $forceNew=false) | |
Connect to database. | |
CreateSequence ($seqname='adodbseq', $startID=1) | |
day ($fld) | |
DBDate ($d, $isfld=false) | |
Converts a date "d" to a string that the database can understand. | |
DBTimeStamp ($ts, $isfld=false) | |
Converts a timestamp "ts" to a string that the database can understand. | |
Disconnect () | |
PEAR DB Compat - do not use internally. | |
DropSequence ($seqname='adodbseq') | |
enableLastInsertID ($enable=true) | |
Enable or disable the Last Insert Id functionality. | |
ErrorMsg () | |
ErrorNative () | |
PEAR DB Compat - do not use internally. | |
ErrorNo () | |
escape ($s, $magic_quotes=false) | |
Alias for addQ() | |
Execute ($sql, $inputarr=false) | |
Execute SQL. | |
FailTrans () | |
At the end of a StartTrans/CompleteTrans block, perform a rollback. | |
GenID ($seqname='adodbseq', $startID=1) | |
Generates a sequence id and stores it in $this->genID. | |
GetActiveRecords ($table, $where=false, $bindarr=false, $primkeyArr=false) | |
GetActiveRecordsClass ( $class, $table, $whereOrderBy=false, $bindarr=false, $primkeyArr=false, $extra=array(), $relations=array()) | |
GetActiveRecordsClass Performs an 'ALL' query. | |
GetAll ($sql, $inputarr=false) | |
Return all rows. | |
GetArray ($sql, $inputarr=false) | |
Executes a statement and returns a the entire recordset in an array. | |
GetAssoc ($sql, $inputarr=false, $force_array=false, $first2cols=false) | |
Execute statement and return rows in an array. | |
getCharSet () | |
Retrieve the client connection's current character set. | |
GetCol ($sql, $inputarr=false, $trim=false) | |
Executes a statement and returns each row's first column in an array. | |
getCustomMetaTypes () | |
Get a list of custom meta types. | |
GetInsertSQL (&$rs, $arrFields, $magic_quotes=false, $force=null) | |
Generates an Insert Query based on an existing recordset. | |
GetMedian ($table, $field, $where='') | |
GetOne ($sql, $inputarr=false) | |
Return first element of first row of sql statement. | |
GetRandRow ($sql, $arr=false) | |
GetRow ($sql, $inputarr=false) | |
Return one row of sql statement. | |
GetUpdateSQL (&$rs, $arrFields, $forceUpdate=false, $magic_quotes=false, $force=null) | |
Generates an Update Query based on an existing recordset. | |
HasFailedTrans () | |
Check if transaction has failed, only for Smart Transactions. | |
IfNull ( $field, $ifNull) | |
IgnoreErrors ($saveErrs=false) | |
InParameter (&$stmt, &$var, $name, $maxLen=4000, $type=false) | |
Self-documenting version of Parameter(). | |
Insert_ID ($table='', $column='') | |
Returns the last inserted ID. | |
IsConnected () | |
Return true if connected to the database. | |
LimitQuery ($sql, $offset, $count, $params=false) | |
PEAR DB Compat - do not use internally. | |
LogSQL ($enable=true) | |
MetaColumnNames ($table, $numIndexes=false, $useattnum=false) | |
List columns names in a table as an array. | |
MetaColumns ($table, $normalize=true) | |
List columns in a database as an array of ADOFieldObjects. | |
MetaDatabases () | |
return the databases that the driver can connect to. | |
MetaError ($err=false) | |
MetaErrorMsg ($errno) | |
metaForeignKeys ($table, $owner='', $upper=false, $associative=false) | |
Returns a list of Foreign Keys associated with a specific table. | |
MetaIndexes ($table, $primary=false, $owner=false) | |
List indexes on a table as an array. | |
MetaPrimaryKeys ($table, $owner=false) | |
MetaProcedures ($procedureNamePattern=null, $catalog=null, $schemaPattern=null) | |
List procedures or functions in an array. | |
MetaTables ($ttype=false, $showSchema=false, $mask=false) | |
MetaTransaction ($mode, $db) | |
MetaType ($t, $len=-1, $fieldobj=false) | |
month ($fld) | |
NConnect ($argHostname="", $argUsername="", $argPassword="", $argDatabaseName="") | |
Always force a new connection to database. | |
nextId ($seq_name) | |
PEAR DB Compat - do not use internally. | |
OffsetDate ($dayFraction, $date=false) | |
Calculate the offset of a date for a particular database and generate appropriate SQL. | |
outp_throw ($msg, $src='WARN', $sql='') | |
Throw an exception if the handler is defined or prints the message if not. | |
OutParameter (&$stmt, &$var, $name, $maxLen=4000, $type=false) | |
Self-documenting version of Parameter(). | |
PageExecute ($sql, $nrows, $page, $inputarr=false, $secs2cache=0) | |
Will select the supplied $page number from a recordset, given that it is paginated in pages of $nrows rows per page. | |
Param ($name, $type='C') | |
Returns a placeholder for query parameters. | |
Parameter (&$stmt, &$var, $name, $isOutput=false, $maxLen=4000, $type=false) | |
Usage in oracle $stmt = $db->Prepare('select * from table where id =:myid and group=:group'); $db->Parameter($stmt,$id,'myid'); $db->Parameter($stmt,$group,'group',64); $db->Execute();. | |
PConnect ($argHostname="", $argUsername="", $argPassword="", $argDatabaseName="") | |
Establish persistent connection to database. | |
PO_Insert_ID ($table="", $id="") | |
Portable Insert ID. | |
Prepare ($sql) | |
Prepare an SQL statement and return the statement resource. | |
PrepareSP ($sql, $param=true) | |
Prepare a Stored Procedure and return the statement resource. | |
q (&$s) | |
Quotes a string so that all strings are escaped. | |
qStr ($s, $magic_quotes=false) | |
Correctly quotes a string so that all strings are escaped. | |
Query ($sql, $inputarr=false) | |
PEAR DB Compat - do not use internally. | |
Quote ($s) | |
PEAR DB Compat - alias for qStr. | |
releaseStatement (&$stmt) | |
Releases a previously prepared statement. | |
Replace ($table, $fieldArray, $keyCol, $autoQuote=false, $has_autoinc=false) | |
Insert or replace a single record. | |
RollbackLock ($table) | |
RollbackTrans () | |
Rolls back a transaction. | |
RowLock ($table, $where, $col='1 as adodbignore') | |
Lock a row. | |
SelectDB ($dbName) | |
Choose a database to connect to. | |
SelectLimit ($sql, $nrows=-1, $offset=-1, $inputarr=false, $secs2cache=0) | |
Select a limited number of rows. | |
SerializableRS (&$rs) | |
Create serializable recordset. | |
ServerInfo () | |
Get server version info. | |
setCharSet ($charset) | |
Sets the client-side character set. | |
setConnectionParameter ($parameter, $value) | |
Adds a parameter to the connection string. | |
setCustomMetaType ( $metaType, $dictionaryType, $actualType, $handleAsType=false, $callback=false) | |
Set a custom meta type with a corresponding actual. | |
SetDateLocale ($locale='En') | |
Change the SQL connection locale to a specified locale. | |
SetFetchMode ($mode) | |
PEAR DB Compat - do not use internally. | |
SetTransactionMode ( $transaction_mode) | |
SQLDate ($fmt, $col='') | |
Format date column in sql string. | |
StartTrans ($errfn='ADODB_TransMonitor') | |
Improved method of initiating a transaction. | |
substr ($fld, $start, $length=0) | |
Returns a substring of a varchar type field. | |
textMax () | |
Returns the maximum size of a MetaType X field. | |
Time () | |
Return the database server's current date and time. | |
updateBlob ($table, $column, $val, $where, $blobtype='BLOB') | |
Update a BLOB column, given a where clause. | |
updateBlobFile ($table, $column, $path, $where, $blobtype='BLOB') | |
Update a BLOB from a file. | |
UpdateClob ($table, $column, $val, $where) | |
Usage: UpdateClob('TABLE', 'COLUMN', $var, 'ID=1', 'CLOB');. | |
UserDate ($v, $fmt='Y-m-d', $gmt=false) | |
Format database date based on user defined format. | |
UserTimeStamp ($v, $fmt='Y-m-d H:i:s', $gmt=false) | |
Format timestamp based on user defined format. | |
year ($fld) | |
Static Public Member Functions | |
static | outp ($msg, $newline=true) |
All error messages go through this bottleneck function. | |
static | UnixDate ($v) |
Also in ADORecordSet. | |
static | UnixTimeStamp ($v) |
Also in ADORecordSet. | |
static | Version () |
ADOdb version. | |
Public Attributes | |
$_affected = false | |
$_bindInputArray = false | |
A boolean variable to state whether its a persistent connection or normal connection. */. | |
resource | $_connectionID = false |
Identifier for the native database connection. | |
$_curs | |
string | $_dropSeqSQL |
SQL statement to drop a Sequence. | |
int false | $_errorCode = false |
Stores the last returned error code. | |
string false | $_errorMsg = false |
Stores the last returned error message. | |
string | $_genIDSQL |
SQL statement to generate a Sequence ID. | |
string | $_genSeqSQL |
SQL statement to create a Sequence . | |
$_initdate = true | |
$_isPersistentConnection = false | |
This variable keeps the last created result link identifier. | |
$_logsql = false | |
ADORecordSet | $_metars |
Recordset used to retrieve MetaType information. | |
$_oldRaiseFn = false | |
$_queryID = false | |
$_transmode = '' | |
$_transOK = null | |
$ansiOuter = false | |
operator to use for right outer join in WHERE clause | |
$arrayClass = 'ADORecordSet_array' | |
$autoCommit = true | |
$autoRollback = false | |
whether ansi outer join syntax supported | |
$blobEncodeType = false | |
$bulkBind = false | |
$cacheSecs = 3600 | |
accepts dates in ISO format | |
$charSet =false | |
right square bracked for t-sql styled column names | |
$concat_operator ='||' | |
$connectSID = true | |
string | $connectStmt = '' |
SQL statement executed by some drivers after successful connection. | |
$customActualTypes = array() | |
$customMetaTypes = array() | |
string | $database = '' |
RDBMS currently in use, eg. odbc, mysql, mssql. | |
$databaseType = "oracle" | |
$dataProvider = 'native' | |
$debug = false | |
Password for the username. For security, we no longer store it. | |
string | $dsnType = '' |
If the driver is PDO, then the dsnType is e.g. | |
$emptyDate = ' ' | |
All order by columns have to be unique. | |
$emptyTimeStamp = ' ' | |
string | $evalAll = false |
set to true if ADOConnection.Execute() permits binding of array parameters. | |
$false = '0' | |
string that represents TRUE for a database | |
$fetchMode =false | |
count of nested transactions | |
$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 | |
bool callable | $fnCacheExecute = false |
Cache execution function to call. | |
bool callable | $fnExecute = false |
Execute function to call. | |
$genID = 0 | |
has transactions | |
$hasAffectedRows = false | |
supports autoincrement ID? | |
$hasGenID = false | |
has ability to run MoveFirst(), scrolling backwards | |
$hasInsertID = false | |
$hasLimit = false | |
support mssql/access SELECT TOP 10 * FROM TABLE | |
$hasMoveFirst = false | |
this is a readonly database - used by phpLens | |
$hasTop = false | |
supports affected rows for update/delete? | |
$hasTransactions = true | |
can generate sequences using GenID(); | |
$host = '' | |
string | $identitySQL |
SQL statement to get the last IDENTITY value inserted into an IDENTITY column in the same scope. | |
$isoDates = false | |
$lastInsID = false | |
$leftBracket = '[' | |
string to use to quote identifiers and names | |
$leftOuter = false | |
indicates that all fields in order by must be unique | |
$length = 'length' | |
substring operator | |
string | $locale |
a specified locale. | |
$maxblobsize = 262144 | |
if set to true will output sql statements | |
bool | $memCache = false |
cache for 1 hour | |
bool | $memCacheCompress = false |
Enable compression of stored items. | |
string array | $memCacheHost |
The memcache server(s) to connect to. | |
array | $memCacheOptions = array() |
An array of memcached options. | |
int | $memCachePort = 11211 |
Default port number. | |
$metaColumnsSQL = "select cname,coltype,width from col where tname='%s' order by colno" | |
string | $metaDatabasesSQL = '' |
character set to use - only for interbase, postgres and oci8 | |
$metaTablesSQL = 'select table_name from cat' | |
$nameQuote = '"' | |
string to use to replace quotes | |
$noNullStrings = false | |
name of class used to generate array recordsets, which are pre-downloaded recordsets | |
$null2null = 'null' | |
$numCacheHits = 0 | |
oracle specific stuff - if true ensures that '' is converted to ' ' | |
$numCacheMisses = 0 | |
$pageExecuteCountRows = true | |
$password = '' | |
The username which is used to connect to the database server. | |
$poorAffectedRows = false | |
$port = '' | |
The hostname of the database server. | |
bool callable | $raiseErrorFn = false |
sequence id used by GenID(); | |
$random = 'rand()' | |
string length ofperator | |
$readOnly = false | |
support pgsql/mysql SELECT * FROM TABLE LIMIT 10 | |
$replaceQuote = "''" | |
$rightBracket = ']' | |
left square bracked for t-sql styled column names | |
$rightOuter = false | |
operator to use for left outer join in WHERE clause | |
$rsPrefix = "ADORecordSet_" | |
$substr = 'substr' | |
default concat operator – change to || for Oracle/Interbase | |
$sysDate = "TO_DATE(TO_CHAR(SYSDATE,'YYYY-MM-DD'),'YYYY-MM-DD')" | |
$sysTimeStamp = 'SYSDATE' | |
$sysUTimeStamp = false | |
name of function that returns the current timestamp | |
$transCnt = 0 | |
temporarily disable transactions | |
$transOff = 0 | |
do not modify this yourself - actually private | |
$true = '1' | |
used by DBTimeStamp as the default timestamp fmt. | |
$uniqueOrderBy = false | |
$uniqueSort = false | |
$upperCase = 'upper' | |
random function | |
$user = '' | |
The port of the database server. | |
Protected Member Functions | |
_insertID ($table='', $column='') | |
Return the id of the last row that has been inserted in a table. | |
getChangedErrorMsg ($old=null) | |
Compare a previously stored error message with the last error recorded by PHP to determine whether a new error has occurred. | |
parseHostNameAndPort () | |
Parses the hostname to extract the port. | |
resetLastError () | |
Get the last error recorded by PHP and clear the message. | |
Protected Attributes | |
array | $connectionParameters = array() |
Additional parameters that may be passed to drivers in the connect string. | |
|
inherited |
Create cache class.
Code is backwards-compatible with old memcache implementation.
|
inherited |
Find version string.
string | $str |
string |
|
inherited |
Private function to generate filename for caching.
Filename is generated based on:
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!
|
protectedinherited |
Return the id of the last row that has been inserted in a table.
string | $table | |
string | $column |
int|false |
Reimplemented in ADODB_ado_mssql, ADODB_db2, ADODB_informix72, ADODB_mssql, ADODB_mssqlnative, ADODB_oci8, ADODB_odbc_mssql, ADODB_odbtp, ADODB_pdo, ADODB_postgres64, ADODB_postgres8, ADODB_sqlite, and ADODB_sybase.
|
inherited |
Always force a new connection to database.
string | $argHostname | Host to connect to |
string | $argUsername | Userid to login |
string | $argPassword | Associated password |
string | $argDatabaseName | Database name |
bool |
Reimplemented in ADODB_mssql, ADODB_oci8, and ADODB_postgres64.
|
inherited |
Convert a database recordset to an array recordset.
Input recordset's cursor should be at beginning, and old $rs will be closed.
ADORecordSet | $rs | the recordset to copy |
int | $nrows | number of rows to retrieve (optional) |
int | $offset | offset by number of rows (optional) |
bool | $close |
ADORecordSet_array|ADORecordSet|bool | the new recordset |
|
inherited |
Quotes a string, without prefixing nor appending quotes.
string | $s | The string to quote |
bool | $magic_quotes | This param is not used since 5.21.0. It remains for backwards compatibility. |
string | Quoted string |
@noinspection PhpUnusedParameterInspection
|
inherited |
int|false | Number of rows affected by UPDATE/DELETE |
|
inherited |
Similar to PEAR DB's autoExecute(), except that $mode can be 'INSERT' or 'UPDATE' or DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE.
If $mode == 'UPDATE', then $where is compulsory as a safety measure.
$table | ||
$fields_values | ||
string | $mode | |
false | $where | |
bool | $forceUpdate | If true, perform update even if the data has not changed. |
bool | $magic_quotes | This param is not used since 5.21.0. It remains for backwards compatibility. |
bool |
@noinspection PhpUnusedParameterInspection
ADODB_oracle::BeginTrans | ( | ) |
Begin a Transaction.
Must be followed by CommitTrans() or RollbackTrans().
bool | true if succeeded or false if database does not support transactions |
Reimplemented from ADOConnection.
ADODB_oracle::BindDate | ( | $d | ) |
Reimplemented from ADOConnection.
ADODB_oracle::BindTimeStamp | ( | $d | ) |
Reimplemented from ADOConnection.
|
inherited |
Reimplemented in ADODB_postgres64.
|
inherited |
Execute SQL, caching recordsets.
int | $secs2cache | Seconds to cache data, set to 0 to force query. This is an optional parameter. |
string | bool | $sql | SQL statement to execute |
array | bool | $inputarr | Holds the input data to bind |
ADORecordSet | RecordSet or false |
|
inherited |
Flush cached recordsets that match a particular $sql statement.
If $sql == false, then we purge all files in the cache.
|
inherited |
Search for the results of an executed query in the cache.
int | $secs2cache | |
string | bool | $sql | SQL statement |
array | bool | $inputarr | input bind array |
bool | $force_array | |
bool | $first2cols |
false|array |
|
inherited |
int | $secs2cache | |
string | false | $sql | |
mixed[] | bool | $inputarr |
mixed[]|bool |
|
inherited |
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.
int | $secs2cache | seconds to cache data, set to 0 to force query |
string | $sql | |
int | $nrows | is the number of rows per page to get |
int | $page | is the page number to get (1-based) |
mixed[] | bool | $inputarr | array of bind variables |
mixed | the recordset ($rs->databaseType == 'array') |
|
inherited |
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
int | $secs2cache | Seconds to cache data, set to 0 to force query. This is optional |
string | $sql | |
int | $offset | Row to start calculations from (1-based) |
int | $nrows | Number of rows to get |
array | $inputarr | Array of bind variables |
ADORecordSet | The recordset ($rs->databaseType == 'array') |
|
inherited |
Returns the maximum size of a MetaType C field.
If the method is not defined in the driver returns ADODB_STRINGMAX_NOTSET
int |
Reimplemented in ADODB_mssqlnative, ADODB_odbc_mssql, and ADODB_sqlite.
|
inherited |
string | $table |
true |
ADODB_oracle::CommitTrans | ( | $ok = true | ) |
Commits a transaction.
If database does not support transactions, return true as data is always committed.
bool | $ok | True to commit, false to rollback the transaction. |
bool | true if successful |
Reimplemented from ADOConnection.
|
inherited |
Complete a transation.
Used together with StartTrans() to end a transaction. Monitors connection for sql errors, and will commit or rollback as appropriate.
bool | autoComplete if true, monitor sql errors and commit and rollback as appropriate, and if set to false force rollback even if no SQL error detected. |
|
inherited |
Concatenate strings.
Different SQL databases used different methods to combine strings together. This function provides a wrapper.
Usage: $db->Concat($str1,$str2);
string | $s | Variable number of string parameters |
string | concatenated string |
Reimplemented in ADODB_mssql, ADODB_mssqlnative, ADODB_odbc_mssql, and ADODB_pdo.
|
inherited |
Connect to database.
string | $argHostname | Host to connect to |
string | $argUsername | Userid to login |
string | $argPassword | Associated password |
string | $argDatabaseName | Database name |
bool | $forceNew | Force new connection |
bool |
ADODB_oracle::DBDate | ( | $d, | |
$isfld = false ) |
Converts a date "d" to a string that the database can understand.
mixed | $d | a date in Unix date time format. |
string | date string in database date format |
Reimplemented from ADOConnection.
ADODB_oracle::DBTimeStamp | ( | $ts, | |
$isfld = false ) |
Converts a timestamp "ts" to a string that the database can understand.
int | object | $ts | A timestamp in Unix date time format. |
string\$timestamp | string in database timestamp format |
Reimplemented from ADOConnection.
|
inherited |
Enable or disable the Last Insert Id functionality.
If the Driver supports it, this function allows setting {
bool | $enable | False to disable |
Reimplemented in ADODB_mssqlnative.
ADODB_oracle::ErrorMsg | ( | ) |
string | the last error message |
Reimplemented from ADOConnection.
|
inherited |
PEAR DB Compat - do not use internally.
int |
ADODB_oracle::ErrorNo | ( | ) |
int | the last error number. Normally 0 means no error. |
Reimplemented from ADOConnection.
|
inherited |
Alias for addQ()
string | $s | |
bool | [$magic_quotes] |
mixed |
|
inherited |
Execute SQL.
string | $sql | SQL statement to execute, or possibly an array holding prepared statement ($sql[0] will hold sql text) |
array | bool | $inputarr | holds the input data to bind to. Null elements will be set to null. |
ADORecordSet|bool |
Reimplemented in ADODB_oci8, and ADODB_oci8po.
|
inherited |
Generates a sequence id and stores it in $this->genID.
GenID is only available if $this->hasGenID = true;
string | $seqname | Name of sequence to use |
int | $startID | If sequence does not exist, start at this ID |
int | Sequence id, 0 if not supported |
Reimplemented in ADODB_ado_mssql, ADODB_ads, ADODB_mssql, ADODB_mssqlnative, ADODB_odbc, ADODB_odbtp, ADODB_pdo, and ADODB_sqlite.
|
inherited |
GetActiveRecordsClass Performs an 'ALL' query.
mixed | $class | This string represents the class of the current active record |
mixed | $table | Table used by the active record object |
mixed | $whereOrderBy | Where, order, by clauses |
mixed | $bindarr | |
mixed | $primkeyArr | |
array | $extra | Query extras: limit, offset... |
mixed | $relations | Associative array: table's foreign name, "hasMany", "belongsTo" |
void |
|
inherited |
Return all rows.
Compat with PEAR DB.
string | $sql | SQL statement |
array | bool | $inputarr | Input bind array |
array|false |
|
inherited |
Executes a statement and returns a the entire recordset in an array.
string | $sql | SQL statement |
array | bool | $inputarr | input bind array |
array|false |
|
inherited |
Execute statement and return rows in an array.
The function executes a statement and returns all of the returned rows in an array, or false if the statement execution fails or if only 1 column is requested in the SQL statement. If no records match the provided SQL statement, an empty array is returned.
string | $sql | SQL statement |
array | bool | $inputarr | input bind array |
bool | $force_array | |
bool | $first2cols |
array|bool |
|
protectedinherited |
Compare a previously stored error message with the last error recorded by PHP to determine whether a new error has occurred.
mixed[] | null | $old | Optional. Previously stored return value of error_get_last(). |
string | The error message if a new error has occurred or an empty string if no (new) errors have occurred.. |
|
inherited |
Retrieve the client connection's current character set.
string|false | The character set, or false if it can't be determined. |
Reimplemented in ADODB_postgres7.
|
inherited |
Executes a statement and returns each row's first column in an array.
string | $sql | SQL statement |
array | bool | $inputarr | input bind array |
bool | $trim | enables space trimming of the returned value. This is only relevant if the returned string is coming from a CHAR type field. |
array|bool | 1D array containning the first row of the query |
|
finalinherited |
Get a list of custom meta types.
string[] |
|
inherited |
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.
$rs | ||
$arrFields | ||
bool | $magic_quotes | This param is not used since 5.21.0. It remains for backwards compatibility. |
null | $force |
false|string |
@noinspection PhpUnusedParameterInspection
|
inherited |
Return first element of first row of sql statement.
Recordset is disposed for you.
string | $sql | SQL statement |
array | bool | $inputarr | input bind array |
mixed |
|
inherited |
Return one row of sql statement.
Recordset is disposed for you. Note that SelectLimit should not be called.
string | $sql | SQL statement |
array | bool | $inputarr | input bind array |
array|false | Array containing the first row of the query |
|
inherited |
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
$rs | ||
$arrFields | ||
bool | $forceUpdate | |
bool | $magic_quotes | This param is not used since 5.21.0. It remains for backwards compatibility. |
null | $force |
false|string |
@noinspection PhpUnusedParameterInspection
|
inherited |
Self-documenting version of Parameter().
$stmt | ||
&$var | ||
$name | ||
int | $maxLen | |
bool | $type |
bool |
Reimplemented in ADODB_pdo.
|
inherited |
Returns the last inserted ID.
Not all databases support this feature. Some do not require to specify table or column name (e.g. MySQL).
string | $table | Table name, default '' |
string | $column | Column name, default '' |
int | The last inserted ID. |
|
inherited |
Return true if connected to the database.
bool |
|
inherited |
List columns names in a table as an array.
table | table name to query |
array | of column names for current table. |
Reimplemented in ADODB_ads.
|
inherited |
List columns in a database as an array of ADOFieldObjects.
See top of file for definition of object.
$table | table name to query |
$normalize | makes table name case-insensitive (required by some databases) @schema is optional database schema to use - not supported by all databases. |
array | of ADOFieldObjects for current table. |
Reimplemented in ADODB_ado, ADODB_ado, ADODB_ado_mssql, ADODB_ads, ADODB_informix72, ADODB_mssql, ADODB_netezza, ADODB_oci8, ADODB_odbc, ADODB_odbc_mssql, ADODB_odbc_oracle, ADODB_odbtp, ADODB_pdo, ADODB_pdo_base, ADODB_postgres64, ADODB_sqlite, and ADODB_sybase_ase.
|
inherited |
return the databases that the driver can connect to.
Some databases will return an empty array.
array|bool | an array of database names. |
Reimplemented in ADODB_mssql, ADODB_mssqlnative, and ADODB_sybase_ase.
|
inherited |
Returns a list of Foreign Keys associated with a specific table.
If there are no foreign keys then the function returns false.
string | $table | The name of the table to get the foreign keys for. |
string | $owner | Table owner/schema. |
bool | $upper | If true, only matches the table with the uppercase name. |
bool | $associative | Returns the result in associative mode; if ADODB_FETCH_MODE is already associative, then this parameter is discarded. |
string[]|false | An array where keys are tables, and values are foreign keys; false if no foreign keys could be found. |
Reimplemented in ADODB_db2, ADODB_informix72, ADODB_mssql, ADODB_mssqlnative, ADODB_oci8, ADODB_odbc_mssql, ADODB_odbtp, ADODB_pdo, and ADODB_postgres7.
|
inherited |
List indexes on a table as an array.
table | table name to query |
primary | true to only show primary keys. Not actually used for most databases |
array | of indexes on current table. Each element represents an index, and is itself an associative array. |
Array( [name_of_index] => Array( [unique] => true or false [columns] => Array( [0] => firstname [1] => lastname ) ) )
Reimplemented in ADODB_mssql, ADODB_mssqlnative, ADODB_oci8, ADODB_odbc_mssql, ADODB_odbtp, ADODB_postgres64, and ADODB_sqlite.
|
inherited |
Reimplemented in ADODB_ads, ADODB_mssql, ADODB_mssqlnative, ADODB_odbc, ADODB_odbc_mssql, ADODB_odbtp, and ADODB_sybase.
|
inherited |
List procedures or functions in an array.
procedureNamePattern | a procedure name pattern; must match the procedure name as it is stored in the database |
catalog | a catalog name; must match the catalog name as it is stored in the database; |
schemaPattern | a schema name pattern; |
array | of procedures on current database. |
Array( [name_of_procedure] => Array( [type] => PROCEDURE or FUNCTION [catalog] => Catalog_name [schema] => Schema_name [remarks] => explanatory comment on the procedure ) )
Reimplemented in ADODB_informix72.
|
inherited |
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 | returns the schema/user with the table name, eg. USER.TABLE |
mask | is the input mask - only supported by oci8 and postgresql |
array | of tables for current database. |
Reimplemented in ADODB_ado, ADODB_ado, ADODB_ads, ADODB_mssql, ADODB_mssqlnative, ADODB_oci8, ADODB_odbc, ADODB_odbc_mssql, ADODB_odbc_oracle, ADODB_odbtp, ADODB_pdo, ADODB_pdo_base, ADODB_postgres64, and ADODB_sybase_ase.
|
inherited |
Always force a new connection to database.
Currently this only works with Oracle.
string | $argHostname | Host to connect to |
string | $argUsername | Userid to login |
string | $argPassword | Associated password |
string | $argDatabaseName | Database name |
bool |
|
inherited |
|
inherited |
Calculate the offset of a date for a particular database and generate appropriate SQL.
Useful for calculating future/past dates and storing in a database.
double | $dayFraction | 1.5 means 1.5 days from now, 1.0/24 for 1 hour |
string | false | $date | Reference date, false for system time |
string |
Reimplemented in ADODB_pdo, and ADODB_postgres64.
|
staticinherited |
All error messages go through this bottleneck function.
You can define your own handler by defining the function name in ADODB_OUTP.
string | $msg | Message to print |
bool | $newline | True to add a newline after printing $msg |
|
inherited |
Throw an exception if the handler is defined or prints the message if not.
string | $msg | Message |
string | $src | the name of the calling function (in uppercase) |
string | $sql | Optional offending SQL statement |
|
inherited |
Self-documenting version of Parameter().
$stmt | ||
$var | ||
$name | ||
int | $maxLen | |
bool | $type |
bool |
|
inherited |
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 docs-adodb.htm#ex8 for an example of usage. NOTE: phpLens uses a different algorithm and does not use PageExecute().
string | $sql | |
int | $nrows | Number of rows per page to get |
int | $page | Page number to get (1-based) |
mixed[] | bool | $inputarr | Array of bind variables |
int | $secs2cache | Private parameter only used by jlim |
mixed | the recordset ($rs->databaseType == 'array') |
|
inherited |
Returns a placeholder for query parameters.
e.g. $DB->Param('a') will return
mixed | $name | parameter's name. For databases that require positioned params (e.g. PostgreSQL), a "falsy" value can be used to force resetting the placeholder count; using boolean 'false' will reset it without actually returning a placeholder. ADOdb will also automatically reset the count when executing a query. |
string | $type | (unused) |
string | query parameter placeholder |
Reimplemented in ADODB_oci8, and ADODB_oci8po.
|
inherited |
Usage in oracle $stmt = $db->Prepare('select * from table where id =:myid and group=:group'); $db->Parameter($stmt,$id,'myid'); $db->Parameter($stmt,$group,'group',64); $db->Execute();.
mixed | &$stmt | Statement returned by Prepare() or PrepareSP(). |
mixed | &$var | PHP variable to bind to |
string | $name | Name of stored procedure variable name to bind to. |
int | bool | $isOutput | Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in oci8. |
int | $maxLen | Holds an maximum length of the variable. |
mixed | $type | The data type of $var. Legal values depend on driver. |
bool |
Reimplemented in ADODB_mssql, ADODB_oci8, and ADODB_odbtp.
|
protectedinherited |
Parses the hostname to extract the port.
Overwrites $this->host and $this->port, only if a port is specified. The Hostname can be fully or partially qualified, ie: "db.mydomain.com:5432" or "ldaps://ldap.mydomain.com:636" Any specified scheme such as ldap:// or ldaps:// is maintained.
|
inherited |
Establish persistent connection to database.
string | $argHostname | Host to connect to |
string | $argUsername | Userid to login |
string | $argPassword | Associated password |
string | $argDatabaseName | Database name |
bool |
|
inherited |
Portable Insert ID.
Pablo Roca <pabloroca\mvps.org>
string | $table | |
string | $id |
mixed | The last inserted ID. All databases support this, but be aware of possible problems in multiuser environments. Heavily test this before deploying. |
|
inherited |
Prepare an SQL statement and return the statement resource.
For databases that do not support prepared statements, we return the provided SQL statement as-is, to ensure compatibility:
$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');
string | $sql | SQL to send to database |
mixed|false | The prepared statement, or the original sql if the database does not support prepare. |
Reimplemented in ADODB_ads, ADODB_mssql, ADODB_mssqlnative, ADODB_odbc, ADODB_odbtp, and ADODB_pdo.
|
inherited |
Prepare a Stored Procedure and return the statement resource.
Some databases, eg. mssql require a different function for preparing stored procedures. So we cannot use Prepare().
For databases that do not support this, we return the $sql.
string | $sql | SQL to send to database |
bool | $param |
mixed|false | The prepared statement, or the original sql if the database does not support prepare. |
Reimplemented in ADODB_mssql, ADODB_mssqlpo, and ADODB_odbtp.
|
inherited |
Quotes a string so that all strings are escaped.
Wrapper for qstr with magic_quotes = false.
string | &$s |
|
inherited |
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"); @externalurl https://adodb.org/dokuwiki/doku.php?id=v5:reference:connection:qstr
string | $s | The string to quote |
bool | $magic_quotes | This param is not used since 5.21.0. It remains for backwards compatibility. |
string | Quoted string to be sent back to database |
@noinspection PhpUnusedParameterInspection
Reimplemented in ADODB_ado_mssql, ADODB_mssql, ADODB_oci8, ADODB_pdo, and ADODB_postgres64.
|
inherited |
PEAR DB Compat - do not use internally.
string | $sql | |
array | bool | $inputarr |
ADORecordSet|bool |
|
inherited |
|
inherited |
Releases a previously prepared statement.
mixed | $stmt | Statement resource, as returned by { |
bool |
Reimplemented in ADODB_oci8.
|
inherited |
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 heuristic 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
|
protectedinherited |
Get the last error recorded by PHP and clear the message.
By clearing the message, it becomes possible to detect whether a new error has occurred, even when it is the same error as before being repeated.
mixed[]|null | Array if an error has previously occurred. Null otherwise. |
|
inherited |
string | $table |
true |
ADODB_oracle::RollbackTrans | ( | ) |
Rolls back a transaction.
If database does not support transactions, return false as rollbacks always fail.
bool | true if successful |
Reimplemented from ADOConnection.
|
inherited |
Lock a row.
Will escalate and lock the table if row locking is not supported. Will normally free the lock at the end of the transaction.
string | $table | name of table to lock |
string | $where | where clause to use, eg: "WHERE row=12". If left empty, will escalate to table lock |
string | $col |
bool |
Reimplemented in ADODB_informix72, ADODB_mssql, ADODB_mssqlnative, ADODB_oci8, ADODB_postgres64, and ADODB_sybase.
|
inherited |
Choose a database to connect to.
Many databases do not support this.
string | $dbName | the name of the database to select |
bool |
Reimplemented in ADODB_ldap, ADODB_mssql, ADODB_mssqlnative, ADODB_oci8, ADODB_odbtp, ADODB_pdo, and ADODB_sybase.
|
inherited |
Select a limited number of rows.
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
string | $sql | |
int | $offset | Row to start calculations from (1-based) |
int | $nrows | Number of rows to get |
array | bool | $inputarr | Array of bind variables |
int | $secs2cache | Private parameter only used by jlim |
ADORecordSet | The recordset ($rs->databaseType == 'array') |
Reimplemented in ADODB_mssql, ADODB_oci805, ADODB_oci8, ADODB_oci8po, ADODB_odbc_mssql, ADODB_odbtp, ADODB_pdo, ADODB_pdo_base, ADODB_postgres7, ADODB_sqlite, and ADODB_sybase.
|
inherited |
Create serializable recordset.
Breaks rs link to connection.
ADORecordSet | $rs | the recordset to serialize |
ADORecordSet_array|bool | the new recordset |
|
inherited |
Get server version info.
string[] | Array with 2 string elements: version and description |
Reimplemented in ADODB_ado, ADODB_ado, ADODB_ads, ADODB_informix72, ADODB_ldap, ADODB_mssql, ADODB_mssqlnative, ADODB_oci8, ADODB_odbc, ADODB_odbc_mssql, ADODB_odbtp, ADODB_pdo, ADODB_pdo_base, and ADODB_sqlite.
|
inherited |
Sets the client-side character set.
This is only supported for some databases.
string | $charset | The character set to switch to. |
bool | True if the character set was changed successfully, false otherwise. |
Reimplemented in ADODB_postgres7.
|
inherited |
Adds a parameter to the connection string.
Parameters must be added before the connection is established; they are then passed on to the connect statement, which will. process them if the driver supports this feature.
Example usage:
If used in a portable environment, parameters set in this manner should be predicated on the database provider, as unexpected results may occur if applied to the wrong database.
string | $parameter | The name of the parameter to set |
string | $value | The value of the parameter |
bool | True if success, false otherwise (e.g. parameter is not valid) |
|
finalinherited |
Set a custom meta type with a corresponding actual.
string | $metaType | The Custom ADOdb metatype |
string | $dictionaryType | The database dictionary type |
string | $actualType | The database actual type |
bool | $handleAsType | handle like an existing Metatype |
mixed | $callBack | A pre-processing function |
bool | success if the actual exists |
|
inherited |
Change the SQL connection locale to a specified locale.
This is used to get the date formats written depending on the client locale.
|
inherited |
|
inherited |
Format date column in sql string.
See https://adodb.org/dokuwiki/doku.php?id=v5:reference:connection:sqldate for documentation on supported formats.
string | $fmt | Format string |
string | $col | Date column; use system date if not specified. |
string |
Reimplemented in ADODB_mssql, ADODB_mssqlnative, ADODB_oci8, ADODB_odbc_mssql, ADODB_pdo, ADODB_postgres64, ADODB_sqlite, and ADODB_sybase.
|
inherited |
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.
|
inherited |
Returns a substring of a varchar type field.
Some databases have variations of the parameters, which is why we have an ADOdb function for it
string | $fld | The field to sub-string |
int | $start | The start point |
int | $length | An optional length |
string | The SQL text |
Reimplemented in ADODB_mssql, ADODB_mssqlnative, and ADODB_odbc_mssql.
|
inherited |
Returns the maximum size of a MetaType X field.
If the method is not defined in the driver returns ADODB_STRINGMAX_NOTSET
int |
Reimplemented in ADODB_mssqlnative, ADODB_odbc_mssql, and ADODB_sqlite.
|
inherited |
Return the database server's current date and time.
int|false |
Reimplemented in ADODB_oci8, and ADODB_pdo.
|
staticinherited |
Also in ADORecordSet.
mixed | $v | is a date string in YYYY-MM-DD format |
int|false | Date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format |
Reimplemented in ADODB_sybase.
|
staticinherited |
Also in ADORecordSet.
string | object | $v | is a timestamp string in YYYY-MM-DD HH-NN-SS format |
int|false | Date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format |
Reimplemented in ADODB_sybase.
|
inherited |
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.
Sample usage:
string | $table | |
string | $column | |
string | $val | Filename containing blob data |
mixed | $where | { |
string | $blobtype | supports 'BLOB' (default) and 'CLOB' |
bool | success |
Reimplemented in ADODB_db2.
|
inherited |
Update a BLOB from a file.
Usage example: $conn->updateBlobFile('table', 'blob_col', '/path/to/file', 'id=1');
string | $table | |
string | $column | |
string | $path | Filename containing blob data |
mixed | $where | { |
string | $blobtype | supports 'BLOB' and 'CLOB' |
bool | success |
|
inherited |
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');
|
inherited |
Format database date based on user defined format.
Also in ADORecordSet.
mixed | $v | Date in YYYY-MM-DD format, returned by database |
string | $fmt | Format to apply, using date() |
bool | $gmt |
string | Formatted date |
|
inherited |
Format timestamp based on user defined format.
mixed | $v | Date in YYYY-MM-DD hh:mm:ss format |
string | $fmt | Format to apply, using date() |
bool | $gmt |
string | Formatted timestamp |
|
staticinherited |
ADOdb version.
string |
|
inherited |
Stores the last returned error code.
Not guaranteed to be used. Only some drivers actually populate it.
|
inherited |
Stores the last returned error message.
|
protectedinherited |
Additional parameters that may be passed to drivers in the connect string.
Data is stored as an array of arrays and not a simple associative array, because some drivers (e.g. mysql) allow multiple parameters with the same key to be set. @externalurl https://github.com/ADOdb/ADOdb/issues/187
$connectionParameters Set of ParameterName => Value pairs
|
inherited |
RDBMS currently in use, eg. odbc, mysql, mssql.
Current database name.
This used to be stored in the $databaseName property, which was marked as deprecated in 4.66 and removed in 5.22.5.
|
inherited |
If the driver is PDO, then the dsnType is e.g.
sqlsrv, otherwise empty
|
inherited |
set to true if ADOConnection.Execute() permits binding of array parameters.
Eval string used to filter data. Only used in the deprecated Text driver.
|
inherited |
SQL statement to get the last IDENTITY value inserted into an IDENTITY column in the same scope.
|
inherited |
cache for 1 hour
Use memCache library instead of caching in files. $memCache
|
inherited |
Enable compression of stored items.
$memCacheCompress
|
inherited |
The memcache server(s) to connect to.
Can be defined as:
|
inherited |
An array of memcached options.
Only used with memcached; memcache ignores this setting. @externalurl https://www.php.net/manual/en/memcached.constants.php $memCacheOptions
|
inherited |
Default port number.
The default port can be overridden if memcache server connection data is provided as an array {
|
inherited |
character set to use - only for interbase, postgres and oci8
SQL statement to get databases
|
inherited |
sequence id used by GenID();
Error function to call