Class: DB
Source Location: /include/database.php
Class DB
Method Summary
| static
void
|
&addq() |
* Quotes a string, without prefixing nor appending quotes. |
| static
void
|
&Affected_Rows() |
* @return # rows affected by UPDATE/DELETE |
| static
void
|
&BeginTrans() |
* Begin a Transaction. Must be followed by CommitTrans() or RollbackTrans(). * * @return true if succeeded or false if database does not support transactions |
| static
void
|
&CacheExecute() |
* Execute SQL, caching recordsets. * * @param [secs2cache] seconds to cache data, set to 0 to force query. * This is an optional parameter. * @param sql SQL statement to execute * @param [inputarr] holds the input data to bind to * @return RecordSet or false |
| static
void
|
&CacheFlush() |
* Flush cached recordsets that match a particular $sql statement. * If $sql == false, then we purge all files in the cache. |
| static
void
|
&CachePageExecute() |
* 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. * * @param secs2cache seconds to cache data, set to 0 to force query * @param sql * @param nrows is the number of rows per page to get * @param page is the page number to get (1-based) * @param [inputarr] array of bind variables * @return the recordset ($rs->databaseType == 'array') |
| static
void
|
&CacheSelectLimit() |
* 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 * * @param [secs2cache] seconds to cache data, set to 0 to force query. This is optional * @param sql * @param [offset] is the row to start calculations from (1-based) * @param [nrows] is the number of rows to get * @param [inputarr] array of bind variables * @return the recordset ($rs->databaseType == 'array') |
| static
void
|
&Close() |
* Close Connection |
| static
void
|
&CommitTrans() |
* If database does not support transactions, always return true as data always commited * * @param $ok set to false to rollback transaction, true to commit * * @return true/false. |
| static
void
|
CompleteTrans() |
Used together with StartTrans() to end a transaction. Monitors connection for sql errors, and will commit or rollback as appropriate. @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. @returns true on commit, false on rollback. |
| static
void
|
&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); * * @return concatenated string |
| static
void
|
Connect() |
Connect to database. |
| static
void
|
&DBDate() |
* Converts a date "d" to a string that the database can understand. * * @param d a date in Unix date time format. * * @return date string in database date format |
| static
void
|
&DBTimeStamp() |
* Converts a timestamp "ts" to a string that the database can understand. * * @param ts a timestamp in Unix date time format. * * @return timestamp string in database timestamp format |
| static
void
|
Disconnect() |
Destroy database connection. |
| static
void
|
&ErrorMsg() |
* @return the last error message |
| static
void
|
&ErrorNo() |
* @return the last error number. Normally 0 means no error. |
| static
void
|
&Execute() |
* Execute SQL * * @param sql SQL statement to execute, or possibly an array holding prepared statement ($sql[0] will hold sql text) * @param [inputarr] holds the input data to bind to. Null elements will be set to null. * @return RecordSet or false |
| static
void
|
&GenID() |
* Generates a sequence id and stores it in $this->genID; * GenID is only available if $this->hasGenID = true; * * @param seqname name of sequence to use * @param startID if sequence does not exist, start at this ID * @return 0 if not supported, otherwise a sequence id |
| static
void
|
&GetArray() |
* * @param sql SQL statement * @param [inputarr] input bind array |
| static
void
|
&GetInsertSQL() |
* 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. |
| static
void
|
&GetOne() |
* Return first element of first row of sql statement. Recordset is disposed * for you. * * @param sql SQL statement * @param [inputarr] input bind array |
| static
integer
|
GetQueries() |
Statistics only. Get number of queries till now. |
| static
void
|
&GetRow() |
* Return one row of sql statement. Recordset is disposed for you. * * @param sql SQL statement * @param [inputarr] input bind array |
| static
void
|
&GetUpdateSQL() |
* Generates an Update Query based on an existing recordset. * $arrFields is an associative array of fields with the value * that should be assigned. * * Note: This function should only be used on a recordset * that is run against a single table and sql should only * be a simple select stmt with no groupby/orderby/limit * * "Jonathan Younger" |
| static
void
|
HasFailedTrans() |
Check if transaction has failed, only for Smart Transactions. |
| static
void
|
&Insert_ID() |
* @param $table string name of the table, not needed by all databases (eg. mysql), default '' * @param $column string name of the column, not needed by all databases (eg. mysql), default '' * @return the last inserted ID. Not all databases support this. |
| static
void
|
&MetaColumnNames() |
* List columns names in a table as an array. * @param table table name to query * * @return array of column names for current table. |
| static
void
|
&MetaColumns() |
* List columns in a database as an array of ADOFieldObjects. * See top of file for definition of object. * * @param $table table name to query * @param $normalize makes table name case-insensitive (required by some databases) * @schema is optional database schema to use - not supported by all databases. * * @return array of ADOFieldObjects for current table. |
| static
void
|
&MetaDatabases() |
* return the databases that the driver can connect to. * Some databases will return an empty array. * * @return an array of database names. |
| static
void
|
&MetaForeignKeys() |
* @returns assoc array where keys are tables, and values are foreign keys |
| static
void
|
&MetaIndexes() |
* List indexes on a table as an array. * @param table table name to query * @param primary true to only show primary keys. Not actually used for most databases * * @return 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 ) ) |
| static
void
|
&MetaPrimaryKeys() |
* @returns an array with the primary key columns in it. |
| static
void
|
&MetaTables() |
* @param 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 * @param showSchema returns the schema/user with the table name, eg. USER.TABLE * @param mask is the input mask - only supported by oci8 and postgresql * * @return array of tables for current database. |
| static
void
|
&PageExecute() |
* Will select the supplied $page number from a recordset, given that it is paginated in pages of * $nrows rows per page. It also saves two boolean values saying if the given page is the first * and/or last one of the recordset. Added by Iván Oliva to provide recordset pagination. * * See readme.htm#ex8 for an example of usage. * * @param sql * @param nrows is the number of rows per page to get * @param page is the page number to get (1-based) * @param [inputarr] array of bind variables * @param [secs2cache] is a private parameter only used by jlim * @return the recordset ($rs->databaseType == 'array') * * NOTE: phpLens uses a different algorithm and does not use PageExecute(). * |
| static
void
|
&PO_Insert_ID() |
* Portable Insert ID. Pablo Roca * * @return the last inserted ID. All databases support this. But aware possible * problems in multiuser environments. Heavy test this before deploying. |
| static
void
|
Prepare() |
* 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 sql SQL to send to database * * @return return FALSE, or the prepared statement, or the original sql if * if the database does not support prepare. * |
| static
void
|
PrepareSP() |
* 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 sql SQL to send to database * * @return return FALSE, or the prepared statement, or the original sql if * if the database does not support prepare. * |
| static
void
|
QMagic() |
Requested by "Karsten Dambekalns" |
| static
void
|
&qstr() |
* 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",magic_quotes_runtime()); * * @param s the string to quote * @param [magic_quotes] if $s is GET/POST var, set to get_magic_quotes_gpc(). * This undoes the stupidity of magic quotes for GPC. * * @return quoted string to be sent back to database |
| static
void
|
Quote() |
* PEAR DB Compat |
| static
void
|
&Replace() |
* Insert or replace a single record. Note: this is not the same as MySQL's replace. * ADOdb's Replace() uses update-insert semantics, not insert-delete-duplicates of MySQL. * Also note that no table locking is done currently, so it is possible that the * record be inserted twice by two programs... * * $this->Replace('products', array('prodname' =>"'Nails'","price" => 3.99), 'prodname'); * * $table table name * $fieldArray associative array of data (you must quote strings yourself). * $keyCol the primary key field name or if compound key, array of field names * autoQuote set to true to use a hueristic to quote strings. Works with nulls and numbers * but does not work with dates nor SQL functions. * has_autoinc the primary key is an auto-inc field, so skip in insert. * * Currently blob replace not supported * * returns 0 = fail, 1 = update, 2 = insert |
| static
void
|
&RollbackTrans() |
* If database does not support transactions, rollbacks always fail, so return false * * @return true/false. |
| static
void
|
RowLock() |
* 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 $table name of table to lock * @param $where where clause to use, eg: "WHERE row=12". If left empty, will escalate to table lock |
| static
void
|
&SelectLimit() |
* 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 * * @param sql * @param [offset] is the row to start calculations from (1-based) * @param [nrows] is the number of rows to get * @param [inputarr] array of bind variables * @param [secs2cache] is a private parameter only used by jlim * @return the recordset ($rs->databaseType == 'array') |
| static
void
|
&SerializableRS() |
* Create serializable recordset. Breaks rs link to connection. * * @param rs the recordset to serialize |
| static
void
|
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). |
| static
void
|
&SetDateLocale() |
* Change the SQL connection locale to a specified locale. * This is used to get the date formats written depending on the client locale. |
| static
void
|
StartTrans() |
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. |
| static
void
|
&UnixDate() |
* Also in ADORecordSet. * @param $v is a date string in YYYY-MM-DD format * * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format |
| static
void
|
&UnixTimeStamp() |
* Also in ADORecordSet. * @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format * * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format |
| static
void
|
&UpdateBlob() |
* Update a blob column, given a where clause. There are more sophisticated * blob handling functions that we could have implemented, but all require * a very complex API. Instead we have chosen something that is extremely * simple to understand and use. * * Note: $blobtype supports 'BLOB' and 'CLOB', default is BLOB of course. * * Usage to update a $blobvalue which has a primary key blob_id=1 into a * field blobtable.blobcolumn: * * UpdateBlob('blobtable', 'blobcolumn', $blobvalue, 'blob_id=1'); * * Insert example: * * $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); * $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1'); |
| static
void
|
&UpdateBlobFile() |
* Usage: * UpdateBlob('TABLE', 'COLUMN', '/path/to/file', 'ID=1'); * * $blobtype supports 'BLOB' and 'CLOB' * * $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); * $conn->UpdateBlob('blobtable','blobcol',$blobpath,'id=1'); |
| static
void
|
&UpdateClob() |
* 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'); |
| static
void
|
&UserDate() |
* Also in ADORecordSet. * * Format database date based on user defined format. * * @param v is the character date in YYYY-MM-DD format, returned by database * @param fmt is the format to apply to it, using date() * * @return a date formated as user desires |
| static
void
|
&UserTimeStamp() |
* * @param v is the character timestamp in YYYY-MM-DD hh:mm:ss format * @param fmt is the format to apply to it, using date() * * @return a timestamp formated as user desires |
Methods
static void &addq(
$s, [
$magic_quotes = false]
)
|
|
* Quotes a string, without prefixing nor appending quotes.
Parameters:
API Tags:
static void &Affected_Rows(
)
|
|
* @return # rows affected by UPDATE/DELETE
API Tags:
static void &AutoExecute(
$table,
$fields_values, [
$mode = 'INSERT'], [
$where = false], [
$forceUpdate = true], [
$magicq = false]
)
|
|
Parameters:
|
|
$table: |
|
|
|
$fields_values: |
|
|
|
$mode: |
|
|
|
$where: |
|
|
|
$forceUpdate: |
|
|
|
$magicq: |
|
API Tags:
static void &BeginTrans(
)
|
|
* Begin a Transaction. Must be followed by CommitTrans() or RollbackTrans(). * * @return true if succeeded or false if database does not support transactions
API Tags:
static void &BindDate(
$d
)
|
|
Parameters:
API Tags:
static void &BindTimeStamp(
$d
)
|
|
Parameters:
API Tags:
static void &BlobDecode(
$blob
)
|
|
Parameters:
API Tags:
static void &BlobEncode(
$blob
)
|
|
Parameters:
API Tags:
static void &CacheExecute(
$secs2cache, [
$sql = false], [
$inputarr = false]
)
|
|
* Execute SQL, caching recordsets. * * @param [secs2cache] seconds to cache data, set to 0 to force query. * This is an optional parameter. * @param sql SQL statement to execute * @param [inputarr] holds the input data to bind to * @return RecordSet or false
Parameters:
|
|
$secs2cache: |
|
|
|
$sql: |
|
|
|
$inputarr: |
|
API Tags:
static void &CacheFlush(
[
$sql = false], [
$inputarr = false]
)
|
|
* Flush cached recordsets that match a particular $sql statement. * If $sql == false, then we purge all files in the cache.
Parameters:
API Tags:
static void &CacheGetAll(
$secs2cache, [
$sql = false], [
$inputarr = false]
)
|
|
Parameters:
|
|
$secs2cache: |
|
|
|
$sql: |
|
|
|
$inputarr: |
|
API Tags:
static void &CacheGetArray(
$secs2cache, [
$sql = false], [
$inputarr = false]
)
|
|
Parameters:
|
|
$secs2cache: |
|
|
|
$sql: |
|
|
|
$inputarr: |
|
API Tags:
static void &CacheGetAssoc(
$secs2cache, [
$sql = false], [
$inputarr = false], [
$force_array = false], [
$first2cols = false]
)
|
|
Parameters:
|
|
$secs2cache: |
|
|
|
$sql: |
|
|
|
$inputarr: |
|
|
|
$force_array: |
|
|
|
$first2cols: |
|
API Tags:
static void &CacheGetCol(
$secs, [
$sql = false], [
$inputarr = false], [
$trim = false]
)
|
|
Parameters:
|
|
$secs: |
|
|
|
$sql: |
|
|
|
$inputarr: |
|
|
|
$trim: |
|
API Tags:
static void &CacheGetOne(
$secs2cache, [
$sql = false], [
$inputarr = false]
)
|
|
Parameters:
|
|
$secs2cache: |
|
|
|
$sql: |
|
|
|
$inputarr: |
|
API Tags:
static void &CacheGetRow(
$secs2cache, [
$sql = false], [
$inputarr = false]
)
|
|
Parameters:
|
|
$secs2cache: |
|
|
|
$sql: |
|
|
|
$inputarr: |
|
API Tags:
static void &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. * * @param secs2cache seconds to cache data, set to 0 to force query * @param sql * @param nrows is the number of rows per page to get * @param page is the page number to get (1-based) * @param [inputarr] array of bind variables * @return the recordset ($rs->databaseType == 'array')
Parameters:
|
|
$secs2cache: |
|
|
|
$sql: |
|
|
|
$nrows: |
|
|
|
$page: |
|
|
|
$inputarr: |
|
API Tags:
static void &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 * * @param [secs2cache] seconds to cache data, set to 0 to force query. This is optional * @param sql * @param [offset] is the row to start calculations from (1-based) * @param [nrows] is the number of rows to get * @param [inputarr] array of bind variables * @return the recordset ($rs->databaseType == 'array')
Parameters:
|
|
$secs2cache: |
|
|
|
$sql: |
|
|
|
$nrows: |
|
|
|
$offset: |
|
|
|
$inputarr: |
|
API Tags:
* Close Connection
API Tags:
static void CommitLock(
$table
)
|
|
Parameters:
API Tags:
static void &CommitTrans(
[
$ok = true]
)
|
|
* If database does not support transactions, always return true as data always commited * * @param $ok set to false to rollback transaction, true to commit * * @return true/false.
Parameters:
API Tags:
static void CompleteTrans(
[
$autoComplete = true]
)
|
|
Used together with StartTrans() to end a transaction. Monitors connection for sql errors, and will commit or rollback as appropriate. @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. @returns true on commit, false on rollback.
Parameters:
API Tags:
* 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); * * @return concatenated string
API Tags:
Connect to database.
API Tags:
static void CreateIndex(
$name,
$tab,
$cols, [
$opts = null]
)
|
|
Parameters:
|
|
$name: |
|
|
|
$tab: |
|
|
|
$cols: |
|
|
|
$opts: |
|
API Tags:
static void &CreateSequence(
[
$seqname = 'adodbseq'], [
$startID = 1]
)
|
|
Parameters:
API Tags:
static void CreateTable(
$name,
$cols, [
$opts = null]
)
|
|
Parameters:
API Tags:
static void &DBDate(
$d
)
|
|
* Converts a date "d" to a string that the database can understand. * * @param d a date in Unix date time format. * * @return date string in database date format
Parameters:
API Tags:
static void &DBTimeStamp(
$ts
)
|
|
* Converts a timestamp "ts" to a string that the database can understand. * * @param ts a timestamp in Unix date time format. * * @return timestamp string in database timestamp format
Parameters:
API Tags:
static void Disconnect(
)
|
|
Destroy database connection.
API Tags:
static void DropIndex(
$name, [
$tab = null]
)
|
|
Parameters:
API Tags:
static void &DropSequence(
[
$seqname = 'adodbseq']
)
|
|
Parameters:
API Tags:
static void DropTable(
$name
)
|
|
Parameters:
API Tags:
* @return the last error message
API Tags:
* @return the last error number. Normally 0 means no error.
API Tags:
static void &escape(
$s, [
$magic_quotes = false]
)
|
|
Parameters:
API Tags:
static void &Execute(
$sql, [
$inputarr = false]
)
|
|
* Execute SQL * * @param sql SQL statement to execute, or possibly an array holding prepared statement ($sql[0] will hold sql text) * @param [inputarr] holds the input data to bind to. Null elements will be set to null. * @return RecordSet or false
Parameters:
API Tags:
static void &GenID(
[
$seqname = 'adodbseq'], [
$startID = 1]
)
|
|
* Generates a sequence id and stores it in $this->genID; * GenID is only available if $this->hasGenID = true; * * @param seqname name of sequence to use * @param startID if sequence does not exist, start at this ID * @return 0 if not supported, otherwise a sequence id
Parameters:
API Tags:
static void &GetActiveRecords(
$table, [
$where = false], [
$bindarr = false], [
$primkeyArr = false]
)
|
|
Parameters:
|
|
$table: |
|
|
|
$where: |
|
|
|
$bindarr: |
|
|
|
$primkeyArr: |
|
API Tags:
static void &GetActiveRecordsClass(
$class,
$table, [
$whereOrderBy = false], [
$bindarr = false], [
$primkeyArr = false]
)
|
|
Parameters:
|
|
$class: |
|
|
|
$table: |
|
|
|
$whereOrderBy: |
|
|
|
$bindarr: |
|
|
|
$primkeyArr: |
|
API Tags:
static void &GetAll(
$sql, [
$inputarr = false]
)
|
|
Parameters:
API Tags:
static void &GetArray(
$sql, [
$inputarr = false]
)
|
|
* * @param sql SQL statement * @param [inputarr] input bind array
Parameters:
API Tags:
static void &GetAssoc(
$sql, [
$inputarr = false], [
$force_array = false], [
$first2cols = false]
)
|
|
Parameters:
|
|
$sql: |
|
|
|
$inputarr: |
|
|
|
$force_array: |
|
|
|
$first2cols: |
|
API Tags:
static void &GetCharSet(
)
|
|
API Tags:
static void &GetCol(
$sql, [
$inputarr = false], [
$trim = false]
)
|
|
Parameters:
API Tags:
static void &GetInsertSQL(
&$rs,
$arrFields, [
$magicq = false], [
$force = NULL]
)
|
|
* Generates an Insert Query based on an existing recordset. * $arrFields is an associative array of fields with the value * that should be assigned. * * Note: This function should only be used on a recordset * that is run against a single table.
Parameters:
|
|
&$rs: |
|
|
|
$arrFields: |
|
|
|
$magicq: |
|
|
|
$force: |
|
API Tags:
static void &GetOne(
$sql, [
$inputarr = false]
)
|
|
* Return first element of first row of sql statement. Recordset is disposed * for you. * * @param sql SQL statement * @param [inputarr] input bind array
Parameters:
API Tags:
static integer GetQueries(
)
|
|
Statistics only. Get number of queries till now.
API Tags:
static void &GetRow(
$sql, [
$inputarr = false]
)
|
|
* Return one row of sql statement. Recordset is disposed for you. * * @param sql SQL statement * @param [inputarr] input bind array
Parameters:
API Tags:
static void &GetUpdateSQL(
&$rs,
$arrFields, [
$forceUpdate = false], [
$magicq = false], [
$force = NULL]
)
|
|
* Generates an Update Query based on an existing recordset. * $arrFields is an associative array of fields with the value * that should be assigned. * * Note: This function should only be used on a recordset * that is run against a single table and sql should only * be a simple select stmt with no groupby/orderby/limit * * "Jonathan Younger"
Parameters:
|
|
&$rs: |
|
|
|
$arrFields: |
|
|
|
$forceUpdate: |
|
|
|
$magicq: |
|
|
|
$force: |
|
API Tags:
static void HasFailedTrans(
)
|
|
Check if transaction has failed, only for Smart Transactions.
API Tags:
static void &IfNull(
$field,
$ifNull
)
|
|
Parameters:
API Tags:
static void IgnoreErrors(
[
$saveErrs = false]
)
|
|
Parameters:
API Tags:
static void InParameter(
&$stmt,
&$var,
$name, [
$maxLen = 4000], [
$type = false]
)
|
|
Parameters:
|
|
&$stmt: |
|
|
|
&$var: |
|
|
|
$name: |
|
|
|
$maxLen: |
|
|
|
$type: |
|
API Tags:
static void &Insert_ID(
[
$table = ''], [
$column = '']
)
|
|
* @param $table string name of the table, not needed by all databases (eg. mysql), default '' * @param $column string name of the column, not needed by all databases (eg. mysql), default '' * @return the last inserted ID. Not all databases support this.
Parameters:
API Tags:
static void &LogSQL(
[
$enable = true]
)
|
|
Parameters:
API Tags:
static void &MetaColumnNames(
$table, [
$numIndexes = false], [
$useattnum = false]
)
|
|
* List columns names in a table as an array. * @param table table name to query * * @return array of column names for current table.
Parameters:
|
|
$table: |
|
|
|
$numIndexes: |
|
|
|
$useattnum: |
|
API Tags:
static void &MetaColumns(
$table, [
$normalize = true]
)
|
|
* List columns in a database as an array of ADOFieldObjects. * See top of file for definition of object. * * @param $table table name to query * @param $normalize makes table name case-insensitive (required by some databases) * @schema is optional database schema to use - not supported by all databases. * * @return array of ADOFieldObjects for current table.
Parameters:
API Tags:
static void &MetaDatabases(
)
|
|
* return the databases that the driver can connect to. * Some databases will return an empty array. * * @return an array of database names.
API Tags:
static void &MetaError(
[
$err = false]
)
|
|
Parameters:
API Tags:
static void &MetaErrorMsg(
$errno
)
|
|
Parameters:
API Tags:
static void &MetaForeignKeys(
$table, [
$owner = false], [
$upper = false]
)
|
|
* @returns assoc array where keys are tables, and values are foreign keys
Parameters:
API Tags:
static void &MetaIndexes(
$table, [
$primary = false], [
$owner = false]
)
|
|
* List indexes on a table as an array. * @param table table name to query * @param primary true to only show primary keys. Not actually used for most databases * * @return 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 ) )
Parameters:
|
|
$table: |
|
|
|
$primary: |
|
|
|
$owner: |
|
API Tags:
static void &MetaPrimaryKeys(
$table, [
$owner = false]
)
|
|
* @returns an array with the primary key columns in it.
Parameters:
API Tags:
static void &MetaTables(
[
$ttype = false], [
$showSchema = false], [
$mask = false]
)
|
|
* @param 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 * @param showSchema returns the schema/user with the table name, eg. USER.TABLE * @param mask is the input mask - only supported by oci8 and postgresql * * @return array of tables for current database.
Parameters:
|
|
$ttype: |
|
|
|
$showSchema: |
|
|
|
$mask: |
|
API Tags:
static void &MetaTransaction(
$mode,
$db
)
|
|
Parameters:
API Tags:
static void &MetaType(
$t, [
$len = -1], [
$fieldobj = false]
)
|
|
Parameters:
API Tags:
static void &OffsetDate(
$dayFraction, [
$date = false]
)
|
|
Parameters:
API Tags:
static void OutParameter(
&$stmt,
&$var,
$name, [
$maxLen = 4000], [
$type = false]
)
|
|
Parameters:
|
|
&$stmt: |
|
|
|
&$var: |
|
|
|
$name: |
|
|
|
$maxLen: |
|
|
|
$type: |
|
API Tags:
static void &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. It also saves two boolean values saying if the given page is the first * and/or last one of the recordset. Added by Iván Oliva to provide recordset pagination. * * See readme.htm#ex8 for an example of usage. * * @param sql * @param nrows is the number of rows per page to get * @param page is the page number to get (1-based) * @param [inputarr] array of bind variables * @param [secs2cache] is a private parameter only used by jlim * @return the recordset ($rs->databaseType == 'array') * * NOTE: phpLens uses a different algorithm and does not use PageExecute(). *
Parameters:
|
|
$sql: |
|
|
|
$nrows: |
|
|
|
$page: |
|
|
|
$inputarr: |
|
|
|
$secs2cache: |
|
API Tags:
static void Param(
$name, [
$type = 'C']
)
|
|
Parameters:
API Tags:
static void Parameter(
&$stmt,
&$var,
$name, [
$isOutput = false], [
$maxLen = 4000], [
$type = false]
)
|
|
Parameters:
|
|
&$stmt: |
|
|
|
&$var: |
|
|
|
$name: |
|
|
|
$isOutput: |
|
|
|
$maxLen: |
|
|
|
$type: |
|
API Tags:
static void &PO_Insert_ID(
[
$table = ''], [
$id = '']
)
|
|
* Portable Insert ID. Pablo Roca * * @return the last inserted ID. All databases support this. But aware possible * problems in multiuser environments. Heavy test this before deploying.
Parameters:
API Tags:
static void 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 sql SQL to send to database * * @return return FALSE, or the prepared statement, or the original sql if * if the database does not support prepare. *
Parameters:
API Tags:
static void 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 sql SQL to send to database * * @return return FALSE, or the prepared statement, or the original sql if * if the database does not support prepare. *
Parameters:
API Tags:
Requested by "Karsten Dambekalns"
Parameters:
API Tags:
static void &qstr(
$s, [
$magic_quotes = false]
)
|
|
* 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",magic_quotes_runtime()); * * @param s the string to quote * @param [magic_quotes] if $s is GET/POST var, set to get_magic_quotes_gpc(). * This undoes the stupidity of magic quotes for GPC. * * @return quoted string to be sent back to database
Parameters:
API Tags:
* PEAR DB Compat
Parameters:
API Tags:
static void RenameColumn(
$tabname,
$oldcolumn,
$newcolumn,
$flds
)
|
|
Parameters:
|
|
$tabname: |
|
|
|
$oldcolumn: |
|
|
|
$newcolumn: |
|
|
|
$flds: |
|
API Tags:
static void &Replace(
$table,
$fieldArray,
$keyCol, [
$autoQuote = false], [
$has_autoinc = false]
)
|
|
* Insert or replace a single record. Note: this is not the same as MySQL's replace. * ADOdb's Replace() uses update-insert semantics, not insert-delete-duplicates of MySQL. * Also note that no table locking is done currently, so it is possible that the * record be inserted twice by two programs... * * $this->Replace('products', array('prodname' =>"'Nails'","price" => 3.99), 'prodname'); * * $table table name * $fieldArray associative array of data (you must quote strings yourself). * $keyCol the primary key field name or if compound key, array of field names * autoQuote set to true to use a hueristic to quote strings. Works with nulls and numbers * but does not work with dates nor SQL functions. * has_autoinc the primary key is an auto-inc field, so skip in insert. * * Currently blob replace not supported * * returns 0 = fail, 1 = update, 2 = insert
Parameters:
|
|
$table: |
|
|
|
$fieldArray: |
|
|
|
$keyCol: |
|
|
|
$autoQuote: |
|
|
|
$has_autoinc: |
|
API Tags:
static void RollbackLock(
$table
)
|
|
Parameters:
API Tags:
static void &RollbackTrans(
)
|
|
* If database does not support transactions, rollbacks always fail, so return false * * @return true/false.
API Tags:
static void 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 $table name of table to lock * @param $where where clause to use, eg: "WHERE row=12". If left empty, will escalate to table lock
Parameters:
API Tags:
static void &SelectLimit(
$sql, [
$nrows = -1], [
$offset = -1], [
$inputarr = false], [
$secs2cache = 0]
)
|
|
* Will select, getting rows from $offset (1-based), for $nrows. * This simulates the MySQL "select * from table limit $offset,$nrows" , and * the PostgreSQL "select * from table limit $nrows offset $offset". Note that * MySQL and PostgreSQL parameter ordering is the opposite of the other. * eg. * SelectLimit('select * from table',3); will return rows 1 to 3 (1-based) * SelectLimit('select * from table',3,2); will return rows 3 to 5 (1-based) * * Uses SELECT TOP for Microsoft databases (when $this->hasTop is set) * BUG: Currently SelectLimit fails with $sql with LIMIT or TOP clause already set * * @param sql * @param [offset] is the row to start calculations from (1-based) * @param [nrows] is the number of rows to get * @param [inputarr] array of bind variables * @param [secs2cache] is a private parameter only used by jlim * @return the recordset ($rs->databaseType == 'array')
Parameters:
|
|
$sql: |
|
|
|
$nrows: |
|
|
|
$offset: |
|
|
|
$inputarr: |
|
|
|
$secs2cache: |
|
API Tags:
static void &SerializableRS(
&$rs
)
|
|
* Create serializable recordset. Breaks rs link to connection. * * @param rs the recordset to serialize
Parameters:
API Tags:
static void 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).
API Tags:
static void &SetCharSet(
$charset
)
|
|
Parameters:
API Tags:
static void &SetDateLocale(
[
$locale = 'En']
)
|
|
* Change the SQL connection locale to a specified locale. * This is used to get the date formats written depending on the client locale.
Parameters:
API Tags:
static void &SetTransactionMode(
$transaction_mode
)
|
|
Parameters:
API Tags:
static void SQLDate(
$fmt, [
$col = false]
)
|
|
Parameters:
API Tags:
static void StartTrans(
[
$errfn = 'ADODB_TransMoni...']
)
|
|
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.
Parameters:
API Tags:
static void &Transpose(
&$rs, [
$addfieldnames = true]
)
|
|
Parameters:
API Tags:
static void TypeControl(
$sql,
&$arr
)
|
|
Parameters:
API Tags:
static void &UnixDate(
$v
)
|
|
* Also in ADORecordSet. * @param $v is a date string in YYYY-MM-DD format * * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
Parameters:
API Tags:
static void &UnixTimeStamp(
$v
)
|
|
* Also in ADORecordSet. * @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format * * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
Parameters:
API Tags:
static void &UpdateBlob(
$table,
$column,
$val,
$where, [
$blobtype = 'BLOB']
)
|
|
* Update a blob column, given a where clause. There are more sophisticated * blob handling functions that we could have implemented, but all require * a very complex API. Instead we have chosen something that is extremely * simple to understand and use. * * Note: $blobtype supports 'BLOB' and 'CLOB', default is BLOB of course. * * Usage to update a $blobvalue which has a primary key blob_id=1 into a * field blobtable.blobcolumn: * * UpdateBlob('blobtable', 'blobcolumn', $blobvalue, 'blob_id=1'); * * Insert example: * * $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); * $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');
Parameters:
|
|
$table: |
|
|
|
$column: |
|
|
|
$val: |
|
|
|
$where: |
|
|
|
$blobtype: |
|
API Tags:
static void &UpdateBlobFile(
$table,
$column,
$path,
$where, [
$blobtype = 'BLOB']
)
|
|
* Usage: * UpdateBlob('TABLE', 'COLUMN', '/path/to/file', 'ID=1'); * * $blobtype supports 'BLOB' and 'CLOB' * * $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); * $conn->UpdateBlob('blobtable','blobcol',$blobpath,'id=1');
Parameters:
|
|
$table: |
|
|
|
$column: |
|
|
|
$path: |
|
|
|
$where: |
|
|
|
$blobtype: |
|
API Tags:
static void &UpdateClob(
$table,
$column,
$val,
$where
)
|
|
* Usage: * UpdateClob('TABLE', 'COLUMN', $var, 'ID=1', 'CLOB'); * * $conn->Execute('INSERT INTO clobtable (id, clobcol) VALUES (1, null)'); * $conn->UpdateClob('clobtable','clobcol',$clob,'id=1');
Parameters:
|
|
$table: |
|
|
|
$column: |
|
|
|
$val: |
|
|
|
$where: |
|
API Tags:
static void &UserDate(
$v, [
$fmt = 'Y-m-d'], [
$gmt = false]
)
|
|
* Also in ADORecordSet. * * Format database date based on user defined format. * * @param v is the character date in YYYY-MM-DD format, returned by database * @param fmt is the format to apply to it, using date() * * @return a date formated as user desires
Parameters:
API Tags:
static void &UserTimeStamp(
$v, [
$fmt = 'Y-m-d H:i:s'], [
$gmt = false]
)
|
|
* * @param v is the character timestamp in YYYY-MM-DD hh:mm:ss format * @param fmt is the format to apply to it, using date() * * @return a timestamp formated as user desires
Parameters:
API Tags:
static void &xCacheFlush(
[
$sql = false], [
$inputarr = false]
)
|
|
Parameters:
API Tags:
|
|