Class ADORecordSet

Description

RecordSet class that represents the dataset returned by the database.

To keep memory overhead low, this class holds only the current row in memory. No prefetching of data is done, so the RecordCount() can return -1 ( which means recordcount not known).

Located in /3rd/adodb/adodb.inc.php (line 2452)

ADODB_BASE_RS
   |
   --ADORecordSet
Direct descendents
Class Description
 class ADORecordSet_array This class encapsulates the concept of a recordset created in memory as an array. This is useful for the creation of cached recordsets.
 class RecordSet class that represents the dataset returned by the database.
 class ADORecordSet_fbsql RecordSet class that represents the dataset returned by the database.
 class ADORecordset_ibase RecordSet class that represents the dataset returned by the database.
 class ADORecordset_informix72 RecordSet class that represents the dataset returned by the database.
 class ADORecordSet_ldap RecordSet class that represents the dataset returned by the database.
 class ADORecordset_mssql RecordSet class that represents the dataset returned by the database.
 class ADORecordSet_mysql RecordSet class that represents the dataset returned by the database.
 class ADORecordSet_mysqli RecordSet class that represents the dataset returned by the database.
 class ADORecordset_oci8 RecordSet class that represents the dataset returned by the database.
 class ADORecordSet_odbc RecordSet class that represents the dataset returned by the database.
 class ADORecordSet_odbtp RecordSet class that represents the dataset returned by the database.
 class ADORecordset_oracle RecordSet class that represents the dataset returned by the database.
 class ADORecordSet_pdo RecordSet class that represents the dataset returned by the database.
 class ADORecordSet_postgres64 RecordSet class that represents the dataset returned by the database.
 class ADORecordset_sqlite RecordSet class that represents the dataset returned by the database.
 class ADORecordset_sybase RecordSet class that represents the dataset returned by the database.
Variable Summary
 mixed $bind
 mixed $blobSize
 mixed $canSeek
 mixed $connection
 mixed $datetime
 mixed $debug
 mixed $emptyDate
 mixed $EOF
 mixed $fetchMode
 mixed $fields
 mixed $sql
 mixed $timeCreated
 mixed $_atLastPage
 mixed $_closed
 mixed $_currentRow
 mixed $_inited
 mixed $_lastPageNo
 mixed $_names
 mixed $_numOfRows
 mixed $_obj
 mixed $_queryID
Method Summary
 ADORecordSet ADORecordSet (queryID $queryID)
 void AbsolutePage ([ $page = -1])
 void AtFirstPage ([ $status = false])
 void AtLastPage ([ $status = false])
 true Close ()
 the CurrentRow ()
 the &FetchField (fieldoffset $fieldoffset)
 DB_OK FetchInto ( &$arr)
 the &FetchNextObj ()
 the &FetchNextObject ([$isupper $isupper = true])
 the &FetchObj ()
 the &FetchObject ([$isupper $isupper = true])
 false &FetchRow ()
 the FieldCount ()
 the Fields (colname $colname)
 void Free ()
 void &GetAll ([ $nRows = -1])
 an &GetArray ([[nRows] $nRows = -1])
 an &GetArrayLimit (offset $nrows, [[nrows] $offset = -1])
 an &GetAssoc ([[force_array] $force_array = false], [[first2cols] $first2cols = false])
 void GetAssocKeys ([ $upper = true])
 HTML GetMenu (name $name, [[defstr] $defstr = ''], [[blank1stItem] $blank1stItem = true], [[multiple] $multiple = false], [[size] $size = 0], [[selectAttr] $selectAttr = ''], [ $compareFields0 = true])
 void GetMenu2 ( $name, [ $defstr = ''], [ $blank1stItem = true], [ $multiple = false], [ $size = 0], [ $selectAttr = ''])
 void GetMenu3 ( $name, [ $defstr = ''], [ $blank1stItem = true], [ $multiple = false], [ $size = 0], [ $selectAttr = ''])
 void &GetRowAssoc ([ $upper = 1])
 an &GetRows ([[nRows] $nRows = -1])
 void Init ()
 void LastPageNo ([ $page = false])
 void MaxRecordCount ()
 the MetaType (t $t, [len $len = -1], [fieldobj $fieldobj = false])
 true Move ([rowNumber $rowNumber = 0])
 true MoveFirst ()
 true MoveLast ()
 true MoveNext ()
 void NextRecordSet ()
 void NumCols ()
 void NumRows ()
 the PO_RecordCount ([ $table = ""], [ $condition = ""])
 the RecordCount ()
 the RowCount ()
 date UnixDate ($v $v)
 date UnixTimeStamp ($v $v)
 a UserDate (v $v, [fmt $fmt = 'Y-m-d'])
 a UserTimeStamp (v $v, [fmt $fmt = 'Y-m-d H:i:s'])
 void _close ()
Variables
mixed $blobSize = 100 (line 2458)
mixed $connection = false (line 2471)
mixed $dataProvider = "native" (line 2456)

Redefined in descendants as:
mixed $datetime = false (line 2489)
mixed $debug = false (line 2466)
mixed $emptyDate = ' ' (line 2465)
mixed $emptyTimeStamp = ' ' (line 2464)
mixed $EOF = false (line 2462)
mixed $fetchMode (line 2470)
mixed $fields = false (line 2457)
mixed $sql (line 2461)

Redefined in descendants as:
mixed $timeCreated (line 2467)
mixed $_atFirstPage = false (line 2485)

Added by Iván Oliva to implement recordset pagination

mixed $_atLastPage = false (line 2486)

Added by Iván Oliva to implement recordset pagination

mixed $_closed = false (line 2479)

This variable keeps the current row in the Recordset.

mixed $_currentPage = -1 (line 2484)

Used by FetchObj

mixed $_currentRow = -1 (line 2478)

This variable keeps the result link identifier.

mixed $_inited = false (line 2480)

has recordset been closed

mixed $_lastPageNo = -1 (line 2487)

Added by Iván Oliva to implement recordset pagination

mixed $_maxRecordCount = 0 (line 2488)
mixed $_names (line 2482)

Used by FetchObj

mixed $_numOfFields = -1 (line 2476)

number of rows, or -1

mixed $_numOfRows = -1 (line 2475)
mixed $_obj (line 2481)

Init() should only be called once

mixed $_queryID = -1 (line 2477)

number of fields in recordset

Methods
Constructor ADORecordSet (line 2497)

Constructor

ADORecordSet ADORecordSet (queryID $queryID)
  • queryID $queryID: this is the queryID returned by ADOConnection->_query()
AbsolutePage (line 3378)

set/returns the current recordset page when paginating

void AbsolutePage ([ $page = -1])
  • $page
AbsolutePosition (line 3098)

synonym for CurrentRow -- for ADO compat

  • return: current row in the recordset. If at EOF, will return the last row. 0-based.
the AbsolutePosition ()
AtFirstPage (line 3387)

set/returns the status of the atFirstPage flag when paginating

void AtFirstPage ([ $status = false])
  • $status
AtLastPage (line 3402)

set/returns the status of the atLastPage flag when paginating

void AtLastPage ([ $status = false])
  • $status
Close (line 3029)

Clean up recordset

  • return: or false
true Close ()
CurrentRow (line 3091)
  • return: current row in the recordset. If at EOF, will return the last row. 0-based.
the CurrentRow ()
FetchInto (line 2862)

Fetch a row, returning PEAR_Error if no more rows.

This is PEAR DB compat mode.

  • return: or error object
DB_OK FetchInto ( &$arr)
  • &$arr
FetchNextObj (line 3184)

Return the fields array of the current row as an object for convenience.

The default is lower-case field names.

  • return:

    object with the properties set to the fields of the current row, or false if EOF

    Fixed bug reported by tim@orotech.net

the &FetchNextObj ()
FetchNextObject (line 3202)

Return the fields array of the current row as an object for convenience.

The default is upper case field names.

  • return:

    object with the properties set to the fields of the current row, or false if EOF

    Fixed bug reported by tim@orotech.net

the &FetchNextObject ([$isupper $isupper = true])
  • $isupper $isupper: to set the object property names to uppercase
FetchObj (line 3137)

Return the fields array of the current row as an object for convenience.

The default case is lowercase field names.

  • return: object with the properties set to the fields of the current row
the &FetchObj ()
FetchObject (line 3151)

Return the fields array of the current row as an object for convenience.

The default case is uppercase.

  • return: object with the properties set to the fields of the current row
the &FetchObject ([$isupper $isupper = true])
  • $isupper $isupper: to set the object property names to uppercase
FetchRow (line 2843)

Fetch a row, returning false if no more rows.

This is PEAR DB compat mode.

  • return: or array containing the current record
false &FetchRow ()
FieldCount (line 3104)
  • return: number of columns in the recordset. Some databases will set this to 0 if no records are returned, others will return the number of columns in the query.
the FieldCount ()
Fields (line 2983)

Get the value of a field in the current row by column name.

Will not work if ADODB_FETCH_MODE is set to ADODB_FETCH_NUM.

  • return: value of $colname column
the Fields (colname $colname)
  • colname $colname: is the field to access

Redefined in descendants as:
FieldTypesArray (line 3123)

Get the ADOFieldObjects of all columns in an array.

void &FieldTypesArray ()
Free (line 2814)

PEAR DB Compat - do not use internally

void Free ()
GetAll (line 2602)
void &GetAll ([ $nRows = -1])
  • $nRows
GetArray (line 2588)

return recordset as a 2-dimensional array.

  • return: array indexed by the rows (0-based) from the recordset
an &GetArray ([[nRows] $nRows = -1])
  • [nRows] $nRows: is the number of rows to return. -1 means every row.

Redefined in descendants as:
GetArrayLimit (line 2626)

return recordset as a 2-dimensional array.

Helper function for ADOConnection->SelectLimit()

  • return: array indexed by the rows (0-based) from the recordset
an &GetArrayLimit (offset $nrows, [[nrows] $offset = -1])
  • offset $nrows: is the row to start calculations from (1-based)
  • [nrows] $offset: is the number of rows to return

Redefined in descendants as:
GetAssoc (line 2675)

return whole recordset as a 2-dimensional associative array if there are more than 2 columns.

The first column is treated as the key and is not included in the array. If there is only 2 columns, it will return a 1 dimensional array of key-value pairs unless $force_array == true.

  • return: associative array indexed by the first column of the array, or false if the data has less than 2 cols.
an &GetAssoc ([[force_array] $force_array = false], [[first2cols] $first2cols = false])
  • [force_array] $force_array: has only meaning if we have 2 data columns. If false, a 1 dimensional array is returned, otherwise a 2 dimensional array is returned. If this sounds confusing, read the source.
  • [first2cols] $first2cols: means if there are more than 2 cols, ignore the remaining cols and instead of returning array[col0] => array(remaining cols), return array[col0] => col1

Redefined in descendants as:
GetAssocKeys (line 2988)
void GetAssocKeys ([ $upper = true])
  • $upper
GetMenu (line 2545)

Generate a SELECT tag string from a recordset, and return the string.

If the recordset has 2 cols, we treat the 1st col as the containing the text to display to the user, and 2nd col as the return value. Default strings are compared with the FIRST column.

  • return: changes by glen.davies@cce.ac.nz to support multiple hilited items
HTML GetMenu (name $name, [[defstr] $defstr = ''], [[blank1stItem] $blank1stItem = true], [[multiple] $multiple = false], [[size] $size = 0], [[selectAttr] $selectAttr = ''], [ $compareFields0 = true])
  • name $name: name of SELECT tag
  • [defstr] $defstr: the value to hilite. Use an array for multiple hilites for listbox.
  • [blank1stItem] $blank1stItem: true to leave the 1st item in list empty
  • [multiple] $multiple: true for listbox, false for popup
  • [size] $size: #rows to show for listbox. not used by popup
  • [selectAttr] $selectAttr: additional attributes to defined for SELECT tag. useful for holding javascript onChange='...' handlers. column 0 (1st col) if this is true. This is not documented.
  • $compareFields0
GetMenu2 (line 2563)

Generate a SELECT tag string from a recordset, and return the string.

If the recordset has 2 cols, we treat the 1st col as the containing the text to display to the user, and 2nd col as the return value. Default strings are compared with the SECOND column.

void GetMenu2 ( $name, [ $defstr = ''], [ $blank1stItem = true], [ $multiple = false], [ $size = 0], [ $selectAttr = ''])
  • $name
  • $defstr
  • $blank1stItem
  • $multiple
  • $size
  • $selectAttr
GetMenu3 (line 2572)
void GetMenu3 ( $name, [ $defstr = ''], [ $blank1stItem = true], [ $multiple = false], [ $size = 0], [ $selectAttr = ''])
  • $name
  • $defstr
  • $blank1stItem
  • $multiple
  • $size
  • $selectAttr
GetRowAssoc (line 3007)

Use associative array to get fields array for databases that do not support associative arrays. Submitted by Paolo S. Asioli paolo.asioli#libero.it

If you don't want uppercase cols, set $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC before you execute your SQL statement, and access $rs->fields['col'] directly.

$upper 0 = lowercase, 1 = uppercase, 2 = whatever is returned by FetchField

void &GetRowAssoc ([ $upper = 1])
  • $upper

Redefined in descendants as:
GetRows (line 2653)

Synonym for GetArray() for compatibility with ADO.

  • return: array indexed by the rows (0-based) from the recordset
an &GetRows ([[nRows] $nRows = -1])
  • [nRows] $nRows: is the number of rows to return. -1 means every row.
Init (line 2504)
void Init ()

Redefined in descendants as:
LastPageNo (line 3393)
void LastPageNo ([ $page = false])
  • $page
MaxRecordCount (line 3053)
void MaxRecordCount ()
MetaType (line 3238)

Get the metatype of the column. This is used for formatting. This is because many databases use different names for the same type, so we transform the original type to our standardised version which uses 1 character codes:

  • return: general type of the data: C for character < 250 chars X for teXt (>= 250 chars) B for Binary N for numeric or floating point D for date T for timestamp L for logical/Boolean I for integer R for autoincrement counter/integer
the MetaType (t $t, [len $len = -1], [fieldobj $fieldobj = false])
  • t $t: is the type passed in. Normally is ADOFieldObject->type.
  • len $len: is the maximum length of that field. This is because we treat character fields bigger than a certain size as a 'B' (blob).
  • fieldobj $fieldobj: is the field object returned by the database driver. Can hold additional info (eg. primary_key for mysql).

Redefined in descendants as:
Move (line 2933)

Random access to a specific row in the recordset. Some databases do not support access to previous rows in the databases (no scrolling backwards).

  • return: if there still rows available, or false if there are no more rows (EOF).
true Move ([rowNumber $rowNumber = 0])
  • rowNumber $rowNumber: is the row to move to (0-based)
MoveFirst (line 2876)

Move to the first row in the recordset. Many databases do NOT support this.

  • return: or false
true MoveFirst ()

Redefined in descendants as:
MoveLast (line 2888)

Move to the last row in the recordset.

  • return: or false
true MoveLast ()

Redefined in descendants as:
NextRecordSet (line 2612)
void NextRecordSet ()

Redefined in descendants as:
NumCols (line 2832)

PEAR DB compat, number of cols

void NumCols ()
NumRows (line 2823)

PEAR DB compat, number of rows

void NumRows ()
PO_RecordCount (line 3074)

Portable RecordCount. Pablo Roca <pabloroca@mvps.org>

  • return:

    number of records from a previous SELECT. All databases support this.

    But aware possible problems in multiuser environments. For better speed the table must be indexed by the condition. Heavy test this before deploying.

the PO_RecordCount ([ $table = ""], [ $condition = ""])
  • $table
  • $condition
RecordCount (line 3046)

synonyms RecordCount and RowCount

  • return: number of rows or -1 if this is not supported
the RecordCount ()
RowCount (line 3063)

synonyms RecordCount and RowCount

  • return: number of rows or -1 if this is not supported
the RowCount ()
UnixDate (line 2794)
  • return: in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
date UnixDate ($v $v)
  • $v $v: is a date string in YYYY-MM-DD format

Redefined in descendants as:
UnixTimeStamp (line 2805)
  • return: in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
date UnixTimeStamp ($v $v)
  • $v $v: is a timestamp string in YYYY-MM-DD HH-NN-SS format

Redefined in descendants as:
UserDate (line 2777)
  • return: date formated as user desires
a UserDate (v $v, [fmt $fmt = 'Y-m-d'])
  • v $v: is the character date in YYYY-MM-DD format, returned by database
  • fmt $fmt: is the format to apply to it, using date()
UserTimeStamp (line 2760)
  • return: timestamp formated as user desires
a UserTimeStamp (v $v, [fmt $fmt = 'Y-m-d H:i:s'])
  • v $v: is the character timestamp in YYYY-MM-DD hh:mm:ss format
  • fmt $fmt: is the format to apply to it, using date()

Documentation generated on Wed, 23 Jan 2008 19:34:35 -0500 by phpDocumentor 1.4.0