[[v6:reference:Index]]\\
====== ADOdb6 Reference Guide======
See the [[v6:database:feature_comparison|Feature Comparison Matrix]]
===== Class Variables =====
The following items are set inside the [[v6:reference:adoconnectiondefinitions|ADOConnectionDefinitions]] class
| [[v6:reference:adodb_countrecs|$countRecords]] | In database drivers that do not support native recordset counting, controls whether to emulate the functionality |
| [[v6:reference:adodb_force_type|$forceType]] | Changes the behavior of empty and null field handling when updating or creating records |
| [[v6:reference:adodb_fetch_mode|$fetchMode]] | Sets the global array type (numeric or associative) for returned recordsets |
| [[v6:reference:adodb_getone_eof|$getOneEOF]] | Sets the returned value if a valid SQL statement does not match any record when the method [[v6:reference:connection:getone|getOne()]] is executed. |
| [[v6:reference:adodb_lang|$language]] | Sets the language for error messages |
| [[v6:reference:adodb_quote_fieldnames|$quoteFieldNames]] | Quotes, and optionally controls the casing of field name in constructed SQL statements |
| [[v6:reference:adodb_assoc_case|$assocCase]] | Controls the case-specifity of recordset keys returned as associative arrays |
| [[v6:reference:adodb_default_metatype|$defaultMetaType]] | Controls the default value returned if an unknown data type is tested |
===== The Database Connection Object =====
==== Establishing Connections ====
| [[v6:reference:connection:adonewconnection|The ADOConnection Class]] | Create a new connection object |
| [[v6:reference:connection:connect|connect()]] | Establishes a non-persistent connection with a database |
| [[v6:reference:connection:isconnected|isConnected()]] | Indicates if a connection has been established |
| [[v6:reference:connection:nconnect|nConnect()]] | Forces the establishment of a new connection with a database |
| [[v6:reference:connection:pconnect|pConnect()]] | Establishes a persistent connection with a database |
| [[v6:reference:connection:selectdb|selectDb()]] | Select which database to connect to |
| [[v6:reference:connection:close|close()]] | Closes a database connection |
==== Working With Cached Recordsets ====
ADOdb supports the ability to work with cached query results via the use of memory based cache servers. All of the core record retrieval methods work the same as their non-caching equivalents, but also check for the availability of cached results first. This can help reduce database load.
| [[v6:userguide:memcached|Memcached Setup]] | Configuring a memcached server connection |
| [[v6:reference:connection:cacheflush|cacheFlush()]] | Flushes a cached result set |
==== Executing SQL ====
| [[v6:reference:connection:autoexecute|autoExecute()]] | Automatically prepares and executes Insert and Update statements based on supplied parameters |
| [[v6:reference:connection:execute|execute()]] | Executes a provided SQL statement and returns a handle to the result |
| [[v6:reference:connection:getall|getAll()]] | Executes a provided SQL statement and returns the entire recordset into an array |
| [[v6:reference:connection:getassoc|getAssoc()]] | Executes a provided SQL statement and returns the entire recordset into an associatitive array with the value of the first column as a key |
| [[v6:reference:connection:getcol|getCol()]] | Executes a provided SQL statement and returns the first column of each row of he entire recordset into an array |
| [[v6:reference:connection:getmedian|getMedian()]] | Returns the median value of a column in a table |
| [[v6:reference:connection:getone|getOne()]] | Retrieves the first column of the first matching row of an executed SQL statement |
| [[v6:reference:connection:getrow|getRow()]] | Retrieves the first matching row of an executed SQL statement |
| [[v6:reference:connection:replace|replace()]] | Provides a simple single record replacement function |
| [[v6:reference:connection:selectlimit()]] | Executes a provided SQL statement and returns a handle to the result, with the ability to supply a starting offset and record count |
==== Prepared Statements ====
| [[v6:reference:connection:inparameter|inParameter()]] | Sets an input parameter to a stored procedure |
| [[v6:reference:connection:outparameter|outParameter()]] | Receives an output parameter from a stored procedure |
| [[v6:reference:connection:param|param()]] | Returns a database specific parameter placeholder |
| [[v6:reference:connection:prepare|prepare()]] | Prepares an SQL statement and returns a handle to use |
| [[v6:reference:connection:preparesp|prepareSp()]] | Access a stored procedure and returns a handle to the procedure |
==== Generating Database Independent SQL strings ====
| [[v6:reference:connection:addq|addQ()]] | Quotes a string, without prefixing nor appending quotes |
| [[v6:reference:connection:charmax|charMax()]] | Returns the largest length of data that can be inserted into a character field |
| [[v6:reference:connection:concat|concat()]] | Returns a database-specific concatenation of strings |
| [[v6:reference:connection:getupdatesql|getUpdateSQL()]] | Creates a database-specific SQL UPDATE statement based on supplied parameters |
| [[v6:reference:connection:getinsertsql|getInsertSQL()]] | Creates a database-specific SQL INSERT statement based on supplied parameters |
| [[v6:reference:connection:ifnull|ifNull()]] | Replaces a null value with a specified replacement |
| [[v6:reference:connection:qstr|quote()]] | Is a pseudonym for the function [[v6:reference:connection:qstr]] |
| [[v6:reference:connection:qstr|qStr()]] | Appropriately quotes strings with ' characters for insertion into the database |
| [[v6:reference:connection:textmax|textMax()]] | Returns the largest length of data that can be inserted into a text field |
==== Handling Blobs ====
| [[v6:reference:connection:blobdecode|blobDecode()]] || Decodes an encoded blob |
| [[v6:reference:connection:blobencode|blobEncode()]] || Encodes a blob field in preparation for database insertion |
| [[v6:reference:connection:updateblob|updateBlob()]] || Updates a blob field in a table using a syntax similar to autoexecute |
| [[v6:reference:connection:updateblobfile|updateBlobFile()]] || Updates a blob field in a table directly from a disk file using a syntax similar to autoexecute |
| [[v6:reference:connection:updateclob|updateClob()]] || Updates a clob field in a table using a syntax similar to autoexecute |
==== Paging/Scrolling ====
| [[v6:reference:recordset:absolutepage|absolutePage()]] | gets or sets the current page number in a paged recordset |
| [[v6:reference:recordset:atfirstpage|atFirstPage()]] | gets or sets whether at the first page in a paged recordset |
| [[v6:reference:recordset:atlastpage|atLastPage()]] | gets or sets whether at the last page in a paged recordset |
| [[v6:reference:connection:lastpageno|lastPageNo()]] | Returns the page number of the last page in a paged recordset |
| [[v6:reference:recordset:maxrecordcount|maxRecordCount()]] | Returns the maximum number of records that can be returned when paging |
| [[v6:reference:connection:pageexecute|pageExecute()]] | Returns a requested page from a recordset |
==== Transaction Scoping ====
See the [[v6:userguide:transactions|Transaction Management Guide]]
| [[v6:reference:connection:begintrans|beginTrans()]] || Begins a granular transaction |
| [[v6:reference:connection:committrans|commitTrans()]] || Commits a granular transaction |
| [[v6:reference:connection:completetrans|completeTrans()]] || Completes a smart transaction |
| [[v6:reference:connection:failtrans|failTrans()]] || Forces a smart transaction to fail |
| [[v6:reference:connection:hasfailedtrans|hasFailedTrans()]] || Reports if a granular transaction has failed |
| [[v6:reference:connection:rollbacktrans|rollbackTrans()]] || Rollback a smart transaction |
| [[v6:reference:connection:settransactionmode|setTransactionMode()]] || Sets the isolation level of a transaction. |
| [[v6:reference:connection:starttrans|startTrans()]] || Starts a smart transaction |
| [[v6:reference:connection:transcnt|getTransCnt()]] || Returns the nesting level of smart transactions |
==== Fetching Data ====
|[[v6:reference:connection:getfetchmode|getFetchMode()]]|Get the array type for return data|
|[[v6:reference:connection:setfetchmode|setFetchMode()]]|Set the array type for return data|
==== Manipulating Dates & Times ====
| [[v6:reference:connection:binddate|bindDate()]] | Creates a portable date field, for use in bind statements |
| [[v6:reference:connection:bindtimestamp|bindTimeStamp()]] | Creates a portable timestamp field, for use in bind statements |
| [[v6:reference:connection:dbdate|dbDate()]] | Creates a portable date field, for use in SQL statements |
| [[v6:reference:connection:dbtimestamp|dbTimeStamp()]] | Creates a portable timestamp field, for use in SQL statements |
| [[v6:reference:connection:offsetdate|offsetDate()]] | Creates a portable date offset field, for use in SQL statements |
| [[v6:reference:connection:setdatelocale|setDateLocale()]] | Changes the SQL connection to a specified Locale |
| [[v6:reference:connection:sqldate|sqlDate()]] | Returns a portably-formatted date string from a timestamp database column |
| [[v6:reference:connection:unixdate|unixDate()]] | Uses the database connection to create date strings |
| [[v6:reference:connection:unixtimestamp|unixTimeStamp()]] | Uses the database connection to create date/time strings |
==== Row Management ====
|[[v6:reference:connection:affected_rows|affected_rows()]]|Returns the number of rows affected by the last operation|
|[[v6:reference:connection:createsequence|createSequence()]]|Creates a sequence in the database|
|[[v6:reference:connection:dropsequence|dropSequence()]]|Drops a sequence in the database|
|[[v6:reference:connection:genid|genId()]]|A portable method of creating sequence numbers|
|[[v6:reference:connection:insert_id|insert_id()]]|Returns the last auto-increment number for an SQL statement|
|[[v6:reference:connection:rowlock|rowLock()]]|Lock a table row for a duration of a transaction|
==== Error Handling ====
|[[v6:reference:connection:errormsg|errorMsg()]]|Returns a database specific error message|
|[[v6:reference:connection:ignoreerrors|ignoreErrors()]]|Overrides the built-in transaction and error handling status|
|[[v6:reference:connection:metaerror|metaError()]]|Returns a portable error number based on a database specific error|
|[[v6:reference:connection:metaerrormsg|metaErrorMsg()]]|Returns a portable error message based on a portable error number. The language of the message may be controlled by [[v6:reference:adodb_lang|$ADODB_LANG]]|
| [[v6:reference:connection:debuglogmarker|debugLogMarker()]] | Writes a user defined message into the debug log |
====Query Rewriting ====
| [[v6:reference:connection:fnexecute|fnExecute and fnCacheExecute]] || A reference to a function that overrides the execute function |
====== The Recordset Object ======
==== Returns one field ====
|[[v6:reference:recordset:fields|fields()]]|Returns a single field in a single row of the current recordset|
==== PEAR Compatibility ====
This series of functions is designed to duplicate the commands and emulate the functionality provided by the now deprecated [[https://pear.php.net/manual/en/package.database.db.php|PEAR DB]] module. ADOdb also provides an unsupported PEAR Auth connection plugin in the ''/adodb/pear/auth'' directory.
| [[v6:reference:connection:fetchinto|fetchInto()]] | Fetches a recordset into an array |
| [[v6:reference:recordset:fetchnextobj|fetchNextObj()]] | Returns the current row as an object for convenience and advances the record pointer |
| [[v6:reference:recordset:fetchnextobj|fetchNextObject]] | This is a pseudonym for fetchNextObj |
| [[v6:reference:recordset:fetchobj|fetchObj()]] | Returns the current row as an object for convenience |
| [[v6:reference:recordset:fetchobj|fetchObject()]] | This is a pseudonym for fetchObj |
| [[v6:reference:recordset:fetchrow|fetchRow()]] | Reads a row of a result set and advances the recordset pointer |
| [[v6:reference:connection:close|free()]] | Is a pseudonym for **close()** |
| [[v6:reference:connection:getrowassoc|getRowAssoc()]] | Reads a row in associative mode if the recordset fetch mode is numeric |
| [[v6:reference:recordset:numcols|numCols()]] | Returns the number of columns in a row of a returned recordset |
| [[v6:reference:recordset:numrows|numRows()]] | Returns the number of rows in a returned recordset |
==== Returns all rows ====
|[[v6:reference:connection:getarray|getArray()]]|Returns a complete recordset as an array|
|[[v6:reference:connection:getassoc|getAssoc()]]|Returns an associate key/value array, with other options|
|[[v6:reference:connection:getarray|getRows()]]|This function is a pseudonym for [[v6:reference:connection:getarray|getArray()]]|
|[[v6:reference:connection:getrandrow|getRandRow()]]|Returns a random record from a recordset|
==== Scrolling ====
| [[v6:reference:recordset:move|move()]] || Move to the nth record of a recordset |
| [[v6:reference:recordset:movenext|moveNext()]] || Moves the cursor to the next record of the recordset from the current position |
| [[v6:reference:recordset:movefirst|moveFirst()]] || Moves the cursor to the first record of the recordset |
| [[v6:reference:recordset:movelast|moveLast()]] || Moves to the last record of a recordset |
| [[v6:reference:connection:currentrow|AbsolutePosition()]] || absolutePosition() is a pseudonym for currentRow() |
| [[v6:reference:connection:currentrow|currentRow()]] || Returns the current row number of a recordset |
==== Menu generation ====
| [[v6:reference:recordset:getmenu|getMenu()]] | Creates a string containing a single or multi select HTML select box |
| [[v6:reference:recordset:getmenu2|getMenu2()]] | (deprecated) Creates a string containing a basic HTML select box with alternate comparison criteria to getMenu() |
| [[v6:reference:recordset:getmenu3|getMenu3()]] | Creates a string containing a grouped (optgroup) HTML single or muilti-select box |
==== Dates ====
| [[v6:datetime:adodb_date_locale|$dateLocale]] | Sets a default date and time format for the ADOdb date/time library |
| [[v6:reference:connection:unixdate|unixDate()]] | Uses the DBMS to return a timestamp from a date string |
| [[v6:reference:connection:unixtimestamp|unixTimeStamp()]] | Uses the DBMS to return a timestamp from a date/time string |
| [[v6:reference:connection:userdate|userDate()]] | Returns a formatted date string for a user supplied timestamp |
| [[v6:reference:connection:usertimestamp|userTimeStamp()]] | Returns a formatted date/time string for a user supplied timestamp |
==== Recordset Info ====
| [[v6:reference:recordset:nextrecordset|nextRecordSet()]] | In databases that allow accessing of recordsets, retrieves the next set |
| [[v6:reference:connection:po_recordcount|po_recordCount()]]| A Portable record count supported by all databases|
| [[v6:reference:connection:recordcount|recordCount()]]| Interface to the native driver recordCount function |
| [[v6:reference:connection:recordcount|rowCount()]]|Is a synonym for [[v6:reference:connection:recordcount|recordCount()]] |
==== Field Info ====
| [[v6:reference:recordset:fetchfield|fetchField()]] | Returns raw, database specific information about a field |
| [[v6:reference:recordset:fieldcount|fieldCount()]] | Returns the the number of fields in a row of a recordset |
| [[v6:reference:recordset:fieldtypesarray|fieldTypesArray()]] | Returns an array of all the [[v6:dictionary:adofieldobject|ADOFieldObjects]] columns in a row |
==== Recordset Cleanup ====
|[[v6:reference:connection:close|close()]]|Closes both the recordset and database connection|