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
파일 보기 프로젝트 열기: vanilla/vanilla 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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!

보호된 프로퍼티들

프로퍼티 타입 설명
$_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