WACT_UTIL
[ class tree: WACT_UTIL ] [ index: WACT_UTIL ] [ all elements ]

Class: ArrayDataSet

Source Location: /framework/util/arraydataset.inc.php

http://wact.sourceforge.net/index.php/ArrayDataSet

Class Overview


Provides an Iterator over a Recordset of DataSpaces.

Variables

Methods


Child classes:

MutableDataSet
Extends the ArrayDataSet with methods to allow manipulation of the dataset, such adding / removing entire rows as opposed to manipulation of the contents of single rows, as provided by the ArrayDataSet.

Inherited Variables

Inherited Methods


Class Details

Provides an Iterator over a Recordset of DataSpaces.

The recordset/dataset is made up of rows accessed using the Iterator and DataSpace interfaces. It should be exactly analagous to a WACT database recordset.

e.g.

$dataset = array (
    array ('username'=>'jdoe','email'=>'jdoe@hotmail.com'),
    array ('username'=>'rsmith','email'=>'rsmith@cure.org'),
    array ('username'=>'nclark','email'=>'nclark@yahoo.com'),
);
$ds = new ArrayDataSet($dataset);
while ($ds->next()) {
    do_something($ds->get(username));
}

access:  public
todo:  
  • any need for paging setup?
see:  http://wact.sourceforge.net/index.php/ArrayDataSet

Class Variables


$dataset =

var:  The Recordset (an array of arrays)
access:  private
Type:   array

$filter =

var:  filter object
access:  private
Type:   A

$filtered =

var:  Set when a filter is applied to the current row
access:  private
Type:   boolean

$first =

var:  Indicates that the cursor is at the first record (row)
access:  private
Type:   boolean

$row =

var:  The current Record (row) from the Recordset
access:  private
Type:   array

$row_copy =

var:  A duplicate of the current row, used with filters
access:  private
Type:   array

Class Methods


constructor ArrayDataSet



ArrayDataSet ArrayDataSet( array $array)

Parameters:

array   $array   An array of arrays representing a Recordset

method export

Export the current row/dataspace as a dictionary/hash/map

array &export( )

method exportDataSetAsArray

Export the Recordset as an array of row arrays

void exportDataSetAsArray( )

method get

Return an item from the current row by key/name

mixed get( string $name)

Parameters:

string   $name   The item key/name

method getDataSet

Alias for exportDataSetAsArray

void getDataSet( )

API Tags:

deprecated:  

method getPropertyList



void getPropertyList( )

method hasProperty



void hasProperty( mixed $name)

method import

Import a dictionary/hash/map that will replace the current row

void import( array $array)

Parameters:

array   $array  

method importDataSetAsArray

Sets up a Recordset from an array of row arrays

Replaces the current Recordset and resets the internal cursor



void importDataSetAsArray( array $dataset)

Parameters:

array   $dataset  

method isDataSource



void isDataSource( )

method isEmpty

Check whether the current row is empty

void isEmpty( )

method merge

Append a dictionary/hash/map of key value pairs to the current row

Existing keys are overwritten



void merge( array $array)

Parameters:

array   $array  

method next

Moves the internal cursor to the next row of the Recordset

Sets the row accessed by the DataSpace interface to the next row of the Recordset. Returns TRUE if there is another row in the recordset, FALSE otherwise. Calls prepare().



void next( )

method prepare

Filter the current row as apt.

Works on a copy of the row.



void prepare( )

method registerFilter

Register a filter object on the current row.

Filters can be used to transform rows. The filter object must provide a doFilter(&$array) method that filters values from the current row. The filter is passed a copy of the current row.



void registerFilter( object &$filter)

Parameters:

object   $filter  

method remove



void remove( mixed $name)

method removeAll



void removeAll( )

method reset

Reset the internal cursor to the beginning of the Recordset

next() must be called after reset() to access a valid row via the DataSpace methods.



void reset( )

method set

Set the value of an item in the current row

void set( string $name, mixed $value)

Parameters:

string   $name   The item key/name
mixed   $value   The item value
WACT: Copyright 2003 Procata, Inc. Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html)
Documentation generated on Sun, 28 Nov 2004 19:43:55 -0800 by phpDocumentor 1.2.3