ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:userguide:portable_sql

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
v5:userguide:portable_sql [2016/02/27 18:39] mnewnhamv5:userguide:portable_sql [2016/02/27 18:42] mnewnham
Line 34: Line 34:
 ==== Fetch Modes Within Select Statements ==== ==== Fetch Modes Within Select Statements ====
  
-PHP allows you to retrieve database records as arrays. You can choose to have the arrays indexed by field name or number. However different low-level PHP database drivers are inconsistent in their indexing efforts. ADOdb allows you to determine your prefered mode. You set this by setting the variable [[v5:reference:connection:adodb_fetch_mode|$ADODB_FETCH_MODE]] to either of the constants:+PHP allows you to retrieve database records as arrays. You can choose to have the arrays indexed by field name or number. However different low-level PHP database drivers are inconsistent in their indexing efforts. ADOdb allows you to determine your prefered mode. You set this by setting the variable [[v5:reference:adodb_fetch_mode|$ADODB_FETCH_MODE]] to either of the constants:
   * ADODB_FETCH_NUM (for numeric indexes)   * ADODB_FETCH_NUM (for numeric indexes)
   * ADODB_FETCH_ASSOC (using field names as an associative index).   * ADODB_FETCH_ASSOC (using field names as an associative index).
Line 44: Line 44:
 Another problem with SELECTs is that some databases do not return the number of rows retrieved from a select statement. This is because the highest performance databases will return records to you even before the last record has been found. Another problem with SELECTs is that some databases do not return the number of rows retrieved from a select statement. This is because the highest performance databases will return records to you even before the last record has been found.
  
-In ADOdb, [[v5:reference:recordcount]] returns the number of rows returned, or will emulate it by buffering the rows and returning the count after all rows have been returned. This can be disabled for performance reasons when retrieving large recordsets by setting the global variable [[v5:reference:connection:adodb_countrecs|$ADODB_COUNTRECS]] = false. This variable is checked every time a query is executed, so you can selectively choose which recordsets to count.+In ADOdb, [[v5:reference:connection:recordcount|recordCount()]] returns the number of rows returned, or will emulate it by buffering the rows and returning the count after all rows have been returned. This can be disabled for performance reasons when retrieving large recordsets by setting the global variable [[v5:reference:adodb_countrecs|$ADODB_COUNTRECS]] = false. This variable is checked every time a query is executed, so you can selectively choose which recordsets to count.
  
 If you prefer to set ''$ADODB_COUNTRECS'' = false, ADOdb still has the [[v5:reference:connection:po_recordcount|po_recordCount()]] function. This will return the number of rows, or if it is not found, it will return an estimate using ''SELECT COUNT(*)'': If you prefer to set ''$ADODB_COUNTRECS'' = false, ADOdb still has the [[v5:reference:connection:po_recordcount|po_recordCount()]] function. This will return the number of rows, or if it is not found, it will return an estimate using ''SELECT COUNT(*)'':
v5/userguide/portable_sql.txt · Last modified: 2020/12/30 21:32 by peterdd