PHP Класс Prado\Data\TDbDataReader

TDbDataReader represents a forward-only stream of rows from a query result set. To read the current row of data, call {@link read}. The method {@link readAll} returns all the rows in a single array. One can also retrieve the rows of data in TDbDataReader by using foreach: foreach($reader as $row) $row represents a row of data Since TDbDataReader is a forward-only stream, you can only traverse it once. It is possible to use a specific mode of data fetching by setting {@link setFetchMode FetchMode}. See {@link http://www.php.net/manual/en/function.PDOStatement-setFetchMode.php} for more details.
С версии: 3.0
Автор: Qiang Xue ([email protected])
Наследование: extends Prado\TComponent, implements Iterator
Показать файл Открыть проект

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

Метод Описание
__construct ( TDbCommand $command ) Constructor.
bindColumn ( $column, &$value, $dataType = null ) Binds a column to a PHP variable.
close ( ) Closes the reader.
current ( ) : mixed Returns the current row.
getColumnCount ( ) : integer
getIsClosed ( ) : boolean
getRowCount ( ) : integer
key ( ) : integer Returns the index of the current row.
next ( ) Moves the internal pointer to the next row.
nextResult ( ) Advances the reader to the next result when reading the results of a batch of statements.
read ( ) : array | false Advances the reader to the next row in a result set.
readAll ( ) : array Reads the whole result set into an array.
readColumn ( $columnIndex ) : mixed | false Returns a single column from the next row of a result set.
readObject ( $className, $fields ) : mixed | false Returns a single column from the next row of a result set.
rewind ( ) Resets the iterator to the initial state.
setFetchMode ( $mode )
valid ( ) : boolean Returns whether there is a row of data at current position.

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

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

Constructor.
public __construct ( TDbCommand $command )
$command TDbCommand

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

When rows of data are being fetched, the corresponding column value will be set in the variable. Note, the fetch mode must include PDO::FETCH_BOUND.
См. также: http://www.php.net/manual/en/function.PDOStatement-bindColumn.php
public bindColumn ( $column, &$value, $dataType = null )

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

Any further data reading will result in an exception.
public close ( )

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

This method is required by the interface Iterator.
public current ( ) : mixed
Результат mixed the current row.

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

public getColumnCount ( ) : integer
Результат integer the number of columns in the result set. Note, even there's no row in the reader, this still gives correct column number.

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

public getIsClosed ( ) : boolean
Результат boolean whether the reader is closed or not.

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

public getRowCount ( ) : integer
Результат integer number of rows contained in the result. Note, most DBMS may not give a meaningful count. In this case, use "SELECT COUNT(*) FROM tableName" to obtain the number of rows.

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

This method is required by the interface Iterator.
public key ( ) : integer
Результат integer the index of the current row.

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

This method is required by the interface Iterator.
public next ( )

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

This method is only useful when there are multiple result sets returned by the query. Not all DBMS support this feature.
public nextResult ( )

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

Advances the reader to the next row in a result set.
public read ( ) : array | false
Результат array | false the current row, false if no more row available

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

Reads the whole result set into an array.
public readAll ( ) : array
Результат array the result set (each array element represents a row of data). An empty array will be returned if the result contains no row.

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

Returns a single column from the next row of a result set.
public readColumn ( $columnIndex ) : mixed | false
Результат mixed | false the column of the current row, false if no more row available

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

Returns a single column from the next row of a result set.
public readObject ( $className, $fields ) : mixed | false
Результат mixed | false the populated object, false if no more row of data available

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

This method is required by the interface Iterator.
public rewind ( )

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

См. также: http://www.php.net/manual/en/function.PDOStatement-setFetchMode.php
public setFetchMode ( $mode )

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

This method is required by the interface Iterator.
public valid ( ) : boolean
Результат boolean whether there is a row of data at current position.