PHP Class Gdn_DataSet, vanilla

This class is HEAVILY inspired by CodeIgniter (http://www.codeigniter.com). My hat is off to them.
Author: Mark O'Sullivan
Inheritance: implements IteratorAggregate
Afficher le fichier Open project: vanilla/vanilla Class Usage Examples

Méthodes publiques

Свойство Type Description
$Connection Contains a reference to the open database connection. FALSE by default. This property is passed by reference from the Database object. Do not manipulate or assign anything to this property!

Protected Properties

Свойство Type Description
$_DatasetType what type of result is returned from the various methods by default. Either DATASET_TYPE_OBJECT or DATASET_TYPE_ARRAY.
$_EOF boolean
$_Result An array of either objects or associative arrays with the data in this dataset.

Méthodes publiques

Méthode Description
PDOStatement ( PDOStatement &$PDOStatement = false ) Assigns the pdostatement object to this object.
__construct ( $Result = null, $DataSetType = null )
__destruct ( )
clean ( ) Clean sensitive data out of the object.
count ( ) : integer Count elements of this object. This method provides support for the countable interface.
dataSeek ( integer $RowIndex ) Moves the dataset's internal cursor pointer to the specified RowIndex.
datasetType ( boolean $DatasetType = false )
expandAttributes ( string $Name = 'Attributes' )
firstRow ( string $DatasetType = false ) : boolean | array | stdClass Returns the first row or FALSE if there are no rows to return.
format ( string $FormatMethod ) : Gdn_Dataset Format the resultset with the given method.
freePDOStatement ( boolean $DestroyPDOStatement = true ) Free's the result resource referenced by $this->_PDOStatement.
getIterator ( ) Interface method for IteratorAggregate.
importDataset ( array $Resultset ) Allows you to fill this object's result set with a foreign data set in the form of an array of associative arrays (or objects).
index ( array | Traversable $Data, string | array $Columns, array $Options = [] ) : array Index a result array.
join ( array &$Data, array $Columns, array $Options = [] )
lastRow ( string $DatasetType = false ) Returns the last row in the or FALSE if there are no rows to return.
nextRow ( string $DatasetType = false ) Returns the next row or FALSE if there are no more rows.
numFields ( ) Returns the number of fields in the DataSet.
numRows ( string $DatasetType = false ) Returns the number of rows in the DataSet.
previousRow ( string $DatasetType = false ) Returns the previous row in the requested format.
result ( string $DatasetType = false ) Returns an array of data as the specified result type: object or array.
resultArray ( ) : array& Returns an array of associative arrays containing the ResultSet data.
resultObject ( $FormatType = '' ) Returns an array of objects containing the ResultSet data.
row ( integer $RowIndex ) : mixed Returns the requested row index as the requested row type.
unserialize ( array $Fields = ['Attributes', 'Data'] ) Unserialize the fields in the dataset.
value ( string $ColumnName, string $DefaultValue = null ) : mixed Advances to the next row and returns the value from a column.

Méthodes protégées

Méthode Description
_fetchAllRows ( string $DatasetType = false ) Fetches all rows from the PDOStatement object into the resultset.

Method Details

PDOStatement() public méthode

Assigns the pdostatement object to this object.
public PDOStatement ( PDOStatement &$PDOStatement = false )
$PDOStatement PDOStatement The PDO Statement Object being assigned.

__construct() public méthode

public __construct ( $Result = null, $DataSetType = null )

__destruct() public méthode

public __destruct ( )

_fetchAllRows() protected méthode

Fetches all rows from the PDOStatement object into the resultset.
protected _fetchAllRows ( string $DatasetType = false )
$DatasetType string The format in which the result should be returned: object or array. It will fill a different array depending on which type is specified.

clean() public méthode

Clean sensitive data out of the object.
public clean ( )

count() public méthode

Count elements of this object. This method provides support for the countable interface.
public count ( ) : integer
Résultat integer

dataSeek() public méthode

Moves the dataset's internal cursor pointer to the specified RowIndex.
public dataSeek ( integer $RowIndex )
$RowIndex integer The index to seek in the result resource.

datasetType() public méthode

public datasetType ( boolean $DatasetType = false )
$DatasetType boolean

expandAttributes() public méthode

public expandAttributes ( string $Name = 'Attributes' )
$Name string

firstRow() public méthode

Returns the first row or FALSE if there are no rows to return.
public firstRow ( string $DatasetType = false ) : boolean | array | stdClass
$DatasetType string The format in which the result should be returned: object or array.
Résultat boolean | array | stdClass False when empty result set, object or array depending on $DatasetType.

format() public méthode

Format the resultset with the given method.
public format ( string $FormatMethod ) : Gdn_Dataset
$FormatMethod string The method to use with Gdn_Format::To().
Résultat Gdn_Dataset $this pointer for chaining.

freePDOStatement() public méthode

Free's the result resource referenced by $this->_PDOStatement.
public freePDOStatement ( boolean $DestroyPDOStatement = true )
$DestroyPDOStatement boolean

getIterator() public méthode

Interface method for IteratorAggregate.
public getIterator ( )

importDataset() public méthode

Allows you to fill this object's result set with a foreign data set in the form of an array of associative arrays (or objects).
public importDataset ( array $Resultset )
$Resultset array The array of arrays or objects that represent the data to be traversed.

index() public static méthode

Index a result array.
public static index ( array | Traversable $Data, string | array $Columns, array $Options = [] ) : array
$Data array | Traversable The array to index. It is formatted similar to the array returned by Gdn_DataSet::Result().
$Columns string | array The name of the column to index on or an array of columns to index on.
$Options array An array of options for the method. - Sep: The string to seperate index columns by. Default '|'. - Unique: Whether or not the results are unique. - true (default): The index is unique. - false: The index is not unique and each indexed row will be an array or arrays.
Résultat array

join() public static méthode

public static join ( array &$Data, array $Columns, array $Options = [] )
$Data array
$Columns array The columns/table information for the join. Depending on the argument's index it will be interpreted differently. - numeric: This column will come be added to the resulting join. The value can be either a string or a two element array where the second element specifies an alias. - alias: The alias of the child table in the query. - child: The name of the child column. - column: The name of the column to put the joined data into. Can't be used with prefix. - parent: The name of the parent column. - table: The name of the child table in the join. - prefix: The name of the prefix to give the columns. Can't be used with column.
$Options array An array of extra options. - sql: A Gdn_SQLDriver with the child query. - type: The join type, either JOIN_INNER, JOIN_LEFT. This defaults to JOIN_LEFT.

lastRow() public méthode

Returns the last row in the or FALSE if there are no rows to return.
public lastRow ( string $DatasetType = false )
$DatasetType string The format in which the result should be returned: object or array.

nextRow() public méthode

Returns the next row or FALSE if there are no more rows.
public nextRow ( string $DatasetType = false )
$DatasetType string The format in which the result should be returned: object or array.

numFields() public méthode

Returns the number of fields in the DataSet.
public numFields ( )

numRows() public méthode

Returns the number of rows in the DataSet.
public numRows ( string $DatasetType = false )
$DatasetType string The format in which the result should be returned: object or array.

previousRow() public méthode

Returns the previous row in the requested format.
public previousRow ( string $DatasetType = false )
$DatasetType string The format in which the result should be returned: object or array.

result() public méthode

Returns an array of data as the specified result type: object or array.
public result ( string $DatasetType = false )
$DatasetType string The format in which to return a row: object or array. The following values are supported. - DATASET_TYPE_ARRAY: An array of associative arrays. - DATASET_TYPE_OBJECT: An array of standard objects. - FALSE: The current value of the DatasetType property will be used.

resultArray() public méthode

Returns an array of associative arrays containing the ResultSet data.
public resultArray ( ) : array&
Résultat array&

resultObject() public méthode

Returns an array of objects containing the ResultSet data.
public resultObject ( $FormatType = '' )

row() public méthode

Returns the requested row index as the requested row type.
public row ( integer $RowIndex ) : mixed
$RowIndex integer The row to return from the result set. It is zero-based.
Résultat mixed The row at the given index or FALSE if there is no row at the index.

unserialize() public méthode

Unserialize the fields in the dataset.
Since: 2.1
public unserialize ( array $Fields = ['Attributes', 'Data'] )
$Fields array

value() public méthode

Advances to the next row and returns the value from a column.
public value ( string $ColumnName, string $DefaultValue = null ) : mixed
$ColumnName string The name of the column to get the value from.
$DefaultValue string The value to return if there is no data.
Résultat mixed The value from the column or $DefaultValue.

Property Details

$Connection public_oe property

Contains a reference to the open database connection. FALSE by default. This property is passed by reference from the Database object. Do not manipulate or assign anything to this property!
public $Connection

$_DatasetType protected_oe property

what type of result is returned from the various methods by default. Either DATASET_TYPE_OBJECT or DATASET_TYPE_ARRAY.
protected $_DatasetType

$_EOF protected_oe property

protected bool $_EOF
Résultat boolean

$_Result protected_oe property

An array of either objects or associative arrays with the data in this dataset.
protected $_Result