Xataface  2.0alpha2
Xataface Application Framework
 All Data Structures Namespaces Files Functions Variables Groups Pages
Public Member Functions | Data Fields
Dataface_RecordReader Class Reference

A class for reading records from the database. It takes a Xataface query array in the constructor. This can be iterated just like an array, and the records are loaded from the database as needed. It keeps an internal buffer for the actual records so that it doesn't need to make a DB request for every record. More...

Public Member Functions

 __construct (array $query, $bufferSize=30, $previewRecords=true)
 Creates a new record reader.
 __destruct ()
 Destructor. Frees memory.
 rewind ()
 Rewinds the pointer to the beginning of the found set.
 current ()
 Returns the current record.
 key ()
 Returns the index of the current position.
 next ()
 Increments the current position to the next position.
 valid ()
 Checks to see if the current position is valid.

Data Fields

 $previewRecords = true
 True if the loaded records should be previews. (Previews truncate long fields.

Detailed Description

A class for reading records from the database. It takes a Xataface query array in the constructor. This can be iterated just like an array, and the records are loaded from the database as needed. It keeps an internal buffer for the actual records so that it doesn't need to make a DB request for every record.

Usage

$query = array('-table' => 'People', 'country'=>'Canada'); $reader = new Dataface_RecordReader($query); foreach ($reader as $key=>$person){ // do something with $person Dataface_Record object. }

See Also
Dataface_ResultReader for a similar API that works with Raw SQL and StdClass objects.

June 26, 2012

Author
Steve Hannah steve.nosp@m.@web.nosp@m.lite..nosp@m.ca

Definition at line 25 of file RecordReader.php.

Constructor & Destructor Documentation

__construct ( array  $query,
  $bufferSize = 30,
  $previewRecords = true 
)

Creates a new record reader.

Parameters
array$queryThe associative array with the query information.
int$bufferSizeThe size of the buffer.
boolean$previewRecordsWhether to return previews of records. If this is false, then the full records will be returned, even if some of the fields contain a lot of text.

Definition at line 89 of file RecordReader.php.

__destruct ( )

Destructor. Frees memory.

Definition at line 104 of file RecordReader.php.

Member Function Documentation

current ( )

Returns the current record.

Returns
Dataface_Record The current record.

Definition at line 159 of file RecordReader.php.

key ( )

Returns the index of the current position.

Returns
int The current position within the foundset.

Definition at line 168 of file RecordReader.php.

next ( )

Increments the current position to the next position.

Definition at line 175 of file RecordReader.php.

rewind ( )

Rewinds the pointer to the beginning of the found set.

Definition at line 112 of file RecordReader.php.

valid ( )

Checks to see if the current position is valid.

Definition at line 182 of file RecordReader.php.

Field Documentation

$previewRecords = true

True if the loaded records should be previews. (Previews truncate long fields.

boolean

Definition at line 77 of file RecordReader.php.


The documentation for this class was generated from the following file: