$databaseType
$databaseType :
Connection object. For connecting to databases, and executing queries.
_insertid( $table, $column)
Warning from http://www.php.net/manual/function.pg-getlastoid.php: Using a OID as a unique identifier is not generally wise.
Unless you are very careful, you might end up with a tuple having a different OID if a database must be reloaded.
| $table | ||
| $column |
SelectLimit( $sql, $nrows = -1, $offset = -1, $inputarr = false, $secs2cache) : \the
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
| $sql | ||
| $nrows | ||
| $offset | ||
| $inputarr | ||
| $secs2cache |
recordset ($rs->databaseType == 'array')
RowLock( $table, $where, $col = '1 as adodbignore')
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
| $table | name of table to lock |
|
| $where | where clause to use, eg: "WHERE row=12". If left empty, will escalate to table lock |
|
| $col |
qstr( $s, $magic_quotes = false) : \quoted
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());
| $s | ||
| $magic_quotes |
string to be sent back to database
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');
| $table | ||
| $column | ||
| $path | ||
| $where | ||
| $blobtype |
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');
| $table | ||
| $column | ||
| $val | ||
| $where | ||
| $blobtype |
MetaColumns( $table, $normalize = true) : array
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) |
of ADOFieldObjects for current table.
Param(string $name, string $type = 'C') : string
Returns a placeholder for query parameters e.g. $DB->Param('a') will return - '?' for most databases - ':a' for Oracle - '$1', '$2', etc. for PostgreSQL
| string | $name | parameter's name, false to force a reset of the number to 1 (for databases that require positioned params such as PostgreSQL; note that ADOdb will automatically reset this when executing a query ) |
| string | $type | (unused) |
query parameter placeholder
MetaIndexes( $table, $primary = false, $owner = false) : array
List indexes on a table as an array.
| $table | ||
| $primary | ||
| $owner |
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 ) ) )
Prepare( $sql) : \return
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');
| $sql |
FALSE, or the prepared statement, or the original sql if if the database does not support prepare.
PrepareSP( $sql, $param = true) : \return
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:
| $sql | ||
| $param |
FALSE, or the prepared statement, or the original sql if if the database does not support prepare.
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.
| $errfn |
Insert_ID( $table = '', $column = '') : \the
| $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 '' |
last inserted ID. Not all databases support this.
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
| $table | ||
| $fieldArray | ||
| $keyCol | ||
| $autoQuote | ||
| $has_autoinc |
CacheSelectLimit( $secs2cache, $sql, $nrows = -1, $offset = -1, $inputarr = false) : \the
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
| $secs2cache | ||
| $sql | ||
| $nrows | ||
| $offset | ||
| $inputarr |
recordset ($rs->databaseType == 'array')
_gencachename( $sql, $createdir)
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!
| $sql | ||
| $createdir |
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" jyounger@unilab.com
| $rs | ||
| $arrFields | ||
| $forceUpdate | ||
| $magicq | ||
| $force |
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.
| $rs | ||
| $arrFields | ||
| $magicq | ||
| $force |
GetActiveRecordsClass(mixed $class, mixed $table, mixed $whereOrderBy = false, mixed $bindarr = false, mixed $primkeyArr = false, array $extra = array(), mixed $relations = array()) : void
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" |
MetaProcedures( $procedureNamePattern = null, $catalog = null, $schemaPattern = null) : array
List procedures or functions in an array.
| $procedureNamePattern | ||
| $catalog | ||
| $schemaPattern |
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 ) )
PageExecute( $sql, $nrows, $page, $inputarr = false, $secs2cache) : \the
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.
| $sql | ||
| $nrows | ||
| $page | ||
| $inputarr | ||
| $secs2cache |
recordset ($rs->databaseType == 'array')
NOTE: phpLens uses a different algorithm and does not use PageExecute().
CachePageExecute( $secs2cache, $sql, $nrows, $page, $inputarr = false) : \the
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.
| $secs2cache | ||
| $sql | ||
| $nrows | ||
| $page | ||
| $inputarr |
recordset ($rs->databaseType == 'array')