PHP Класс Gdn_DataSet, vanilla

This class is HEAVILY inspired by CodeIgniter (http://www.codeigniter.com). My hat is off to them.
Автор: Mark O'Sullivan
Наследование: implements IteratorAggregate
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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)

Свойство Тип Описание
$_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.

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
_fetchAllRows ( string $DatasetType = false ) Fetches all rows from the PDOStatement object into the resultset.

Описание методов

PDOStatement() публичный Метод

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

__construct() публичный Метод

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

__destruct() публичный Метод

public __destruct ( )

_fetchAllRows() защищенный Метод

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() публичный Метод

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

count() публичный Метод

Count elements of this object. This method provides support for the countable interface.
public count ( ) : integer
Результат integer

dataSeek() публичный Метод

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 datasetType ( boolean $DatasetType = false )
$DatasetType boolean

expandAttributes() публичный Метод

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

firstRow() публичный Метод

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.
Результат boolean | array | stdClass False when empty result set, object or array depending on $DatasetType.

format() публичный Метод

Format the resultset with the given method.
public format ( string $FormatMethod ) : Gdn_Dataset
$FormatMethod string The method to use with Gdn_Format::To().
Результат Gdn_Dataset $this pointer for chaining.

freePDOStatement() публичный Метод

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

getIterator() публичный Метод

Interface method for IteratorAggregate.
public getIterator ( )

importDataset() публичный Метод

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() публичный статический Метод

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.
Результат array

join() публичный статический Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

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

numRows() публичный Метод

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() публичный Метод

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() публичный Метод

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() публичный Метод

Returns an array of associative arrays containing the ResultSet data.
public resultArray ( ) : array&
Результат array&

resultObject() публичный Метод

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

row() публичный Метод

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.
Результат mixed The row at the given index or FALSE if there is no row at the index.

unserialize() публичный Метод

Unserialize the fields in the dataset.
С версии: 2.1
public unserialize ( array $Fields = ['Attributes', 'Data'] )
$Fields array

value() публичный Метод

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.
Результат mixed The value from the column or $DefaultValue.

Описание свойств

$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!
public $Connection

$_DatasetType защищенное свойство

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

$_EOF защищенное свойство

protected bool $_EOF
Результат boolean

$_Result защищенное свойство

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