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

Class: DataSet

Source Location: /jargon/DataSet.php

Class Overview


The DataSet represents the results of a query.


Author(s):

Version:

  • $Revision: 1.5 $

Variables

Constants

Methods


Child classes:

QueryDataSet
This class is used to represent the results of a SQL select statements on the database.
TableDataSet
This class is used for doing select/insert/delete/update on the database.

Class Details

[line 50]
The DataSet represents the results of a query.

It contains a collection of records and implements the IteratorAggregate interface so that you can use the dataset in a foreach() {} loop.

  1. $ds = new TableDataSet($conn, "mytable");
  2. $ds->fetchRecords();
  3. foreach($ds as $record) {
  4. $record->setValue("col1", "new value");
  5. $record->save();
  6. }

This class is extended by QueryDataSet and TableDataSet and should not be used directly.




Tags:

abstract:  
version:  $Revision: 1.5 $
author:  Jon S. Stevens <jon@latchkey.com> (Village)
author:  Hans Lellelid <hans@xmpl.org> (Jargon)


[ Top ]


Class Variables

$allRecordsRetrieved =  false

[line 62]

have all records been retrieved with the fetchRecords?



Tags:

access:  protected

Type:   mixed


[ Top ]

$columns =

[line 74]

the columns in the SELECT statement for this DataSet



Tags:

access:  protected

Type:   mixed


[ Top ]

$conn =

[line 59]

this DataSet's connection object



Tags:

access:  protected

Type:   mixed


[ Top ]

$keyDef =

[line 80]

the KeyDef for this DataSet



Tags:

access:  protected

Type:   mixed


[ Top ]

$lastFetchSize =  0

[line 68]

number of records that were last fetched



Tags:

access:  protected

Type:   mixed


[ Top ]

$recordRetrievedCount =  0

[line 65]

number of records retrieved



Tags:

access:  protected

Type:   mixed


[ Top ]

$records =

[line 56]

this DataSet's collection of Record objects



Tags:

access:  protected

Type:   mixed


[ Top ]

$resultSet =

[line 83]

the result set for this DataSet



Tags:

access:  protected

Type:   mixed


[ Top ]

$selectSql =

[line 77]

the select string that was used to build this DataSet



Tags:

access:  protected

Type:   mixed


[ Top ]

$stmt =

[line 86]

the Statement for this DataSet



Tags:

access:  protected

Type:   mixed


[ Top ]

$totalFetchCount =  0

[line 71]

number of records total that have been fetched



Tags:

access:  protected

Type:   mixed


[ Top ]



Class Methods


method allRecordsRetrieved [line 123]

boolean allRecordsRetrieved( )

Check if all the records have been retrieve



Tags:

return:  True if all records have been retrieved
access:  public


[ Top ]

method clearRecords [line 157]

an clearRecords( )

Remove all records from the DataSet and nulls those records out and close() the DataSet.



Tags:

return:  instance of myself
access:  public


[ Top ]

method close [line 183]

void close( )

Releases the records, closes the ResultSet and the Statement, and nulls the Schema and Connection references.



Tags:

access:  public


[ Top ]

method connection [line 222]

Connection connection( )

Gets the current database connection



Tags:

return:  A database connection.
access:  public


[ Top ]

method containsRecord [line 279]

true containsRecord( pos $pos)

Check to see if the DataSet contains a Record at 0 based position



Tags:

return:  if record exists
access:  public


Parameters:

pos   $pos  

[ Top ]

method fetchRecords [line 298]

DataSet fetchRecords( [int $p1 = 0], [int $p2 = null])

Causes the DataSet to hit the database and fetch max records, starting at start. Record count begins at 0.

This method supports two signatures:

  • fetchRecords(10); // LIMIT = 10
  • fetchRecords(5, 10); // OFFSET = 5, LIMIT = 10




Tags:

return:  This class.
access:  public
throws:  SQLException
throws:  DataSetException


Overridden in child classes as:

TableDataSet::fetchRecords()
Fetch start to max records. start is at Record 0

Parameters:

int   $p1   max - or start if $p2 is set
int   $p2   start

[ Top ]

method findRecord [line 265]

Record findRecord( int $pos)

Find Record at 0 based index position. This is an internal alternative to getRecord which tries to be smart about the type of record it is.



Tags:

return:  an instance of the found Record
access:  public
throws:  DataSetException


Parameters:

int   $pos  

[ Top ]

method getColumns [line 401]

the getColumns( )

Returns the columns attribute for the DataSet



Tags:

return:  columns attribute for the DataSet
access:  public


[ Top ]

method getIterator [line 98]

DataSetIterator getIterator( )

Return iterator (for IteratorAggregate interface).

This allows this class to be used in a foreach() loop.

  1. foreach($dataset as $record) {
  2. print "col1 = " . $record->getValue("col1") . "\n";
  3. }




Tags:

access:  public


[ Top ]

method getRecord [line 244]

Record getRecord( int $pos)

Get Record at 0 based index position



Tags:

return:  An instance of the found Record
access:  public
throws:  DataSetException


Parameters:

int   $pos  

[ Top ]

method getSelectSql [line 394]

string getSelectSql( )

Classes extending this class must implement this method.



Tags:

return:  The SELECT SQL.
abstract:  
access:  public
throws:  DataSetException;


Overridden in child classes as:

QueryDataSet::getSelectSql()
get the Select String that was used to create this QueryDataSet
TableDataSet::getSelectSql()
Builds the select string that was used to populate this TableDataSet.

[ Top ]

method keydef [line 371]

KeyDef keydef( )

gets the KeyDef object for this DataSet



Tags:

return:  The keydef for this DataSet, this value can be null
access:  public


[ Top ]

method lastFetchSize [line 361]

int lastFetchSize( )

The number of records that were fetched with the last fetchRecords.



Tags:

access:  public


[ Top ]

method releaseRecords [line 168]

an releaseRecords( )

Removes the records from the DataSet, but does not null the records out



Tags:

return:  instance of myself
access:  public


[ Top ]

method removeRecord [line 144]

Record removeRecord( Record $rec)

Remove a record from the DataSet's internal storage



Tags:

return:  The record removed
access:  public


Parameters:

Record   $rec  

[ Top ]

method reset [line 208]

DataSet reset( )

Essentially the same as releaseRecords, but it won't work on a QueryDataSet that has been created with a ResultSet



Tags:

return:  This object.
access:  public
throws:  DataSetException


[ Top ]

method resultSet [line 110]

ResultSet resultSet( )

Gets the ResultSet for this DataSet



Tags:

return:  The result set for this DataSet
access:  public
throws:  DataSetException - if resultset is null


[ Top ]

method schema [line 232]

Schema schema( )

Gets the Schema for this DataSet



Tags:

return:  The Schema for this DataSet
access:  public


[ Top ]

method setAllRecordsRetrieved [line 133]

void setAllRecordsRetrieved( boolean $set)

Set all records retrieved



Parameters:

boolean   $set  

[ Top ]

method size [line 411]

int size( )

Gets the number of Records in this DataSet. It is 0 based.



Tags:

return:  Number of Records in this DataSet
access:  public


[ Top ]

method __toString [line 379]

void __toString( )

This returns a represention of this DataSet



Tags:

access:  public


[ Top ]


Class Constants

ALL_RECORDS =  0

[line 53]

indicates that all records should be retrieved during a fetch


[ Top ]



Documentation generated on Mon, 23 Aug 2004 21:51:25 -0400 by phpDocumentor 1.3.0RC3