|
Class TDbDataReader
TDbDataReader class.
TDbDataReader represents a forward-only stream of rows from a query result
set.
To read the current row of data, call TDbDataReader::read() . The method TDbDataReader::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)
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 setFetchMode FetchMode. See http://www.php.net/manual/en/function.PDOStatement-setFetchMode.php
for more details.
-
TComponent
-
TDbDataReader
implements
Iterator
Methods summary
public
|
#
__construct( TDbCommand $command )
Constructor.
Parameters
- $command
TDbCommand
the command generating the query result
Overrides
|
public
|
#
bindColumn( mixed $column, mixed & $value, integer $dataType = null )
Binds a column to a PHP variable. 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.
Binds a column to a PHP variable. 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.
Parameters
- $column
mixed Number of the column (1-indexed) or name of the column in the result set. If
using the column name, be aware that the name should match the case of the
column, as returned by the driver.
- $value
mixed Name of the PHP variable to which the column will be bound.
- $dataType
integer Data type of the parameter
See
|
public
|
#
setFetchMode( mixed $mode )
|
public
array|false
|
#
read( )
Advances the reader to the next row in a result set.
Advances the reader to the next row in a result set.
Returns
array|false the current row, false if no more row available
|
public
mixed|false
|
#
readColumn( integer $columnIndex )
Returns a single column from the next row of a result set.
Returns a single column from the next row of a result set.
Parameters
- $columnIndex
integer zero-based column index
Returns
mixed|false the column of the current row, false if no more row available
|
public
mixed|false
|
#
readObject( string $className, array $fields )
Returns a single column from the next row of a result set.
Returns a single column from the next row of a result set.
Parameters
- $className
string class name of the object to be created and populated
- $fields
array list of column names whose values are to be passed as parameters in the
constructor of the class being created
Returns
mixed|false the populated object, false if no more row of data available
|
public
array
|
#
readAll( )
Reads the whole result set into an array.
Reads the whole result set into an array.
Returns
array the result set (each array element represents a row of data). An empty array
will be returned if the result contains no row.
|
public
|
#
nextResult( )
Advances the reader to the next result when reading the results of a batch of
statements. This method is only useful when there are multiple result sets
returned by the query. Not all DBMS support this feature.
Advances the reader to the next result when reading the results of a batch of
statements. This method is only useful when there are multiple result sets
returned by the query. Not all DBMS support this feature.
|
public
|
#
close( )
Closes the reader. Any further data reading will result in an exception.
Closes the reader. Any further data reading will result in an exception.
|
public
boolean
|
#
getIsClosed( )
Returns
boolean whether the reader is closed or not.
|
public
integer
|
#
getRowCount( )
Returns
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.
|
public
integer
|
#
getColumnCount( )
Returns
integer the number of columns in the result set. Note, even there's no row in the
reader, this still gives correct column number.
|
public
|
#
rewind( )
Resets the iterator to the initial state. This method is required by the
interface Iterator.
Resets the iterator to the initial state. This method is required by the
interface Iterator.
Throws
Implementation of
Iterator::rewind()
|
public
integer
|
#
key( )
Returns the index of the current row. This method is required by the
interface Iterator.
Returns the index of the current row. This method is required by the
interface Iterator.
Returns
integer the index of the current row.
Implementation of
Iterator::key()
|
public
mixed
|
#
current( )
Returns the current row. This method is required by the interface
Iterator.
Returns the current row. This method is required by the interface
Iterator.
Returns
mixed the current row.
Implementation of
Iterator::current()
|
public
|
#
next( )
Moves the internal pointer to the next row. This method is required by the
interface Iterator.
Moves the internal pointer to the next row. This method is required by the
interface Iterator.
Implementation of
Iterator::next()
|
public
boolean
|
#
valid( )
Returns whether there is a row of data at current position. This method is
required by the interface Iterator.
Returns whether there is a row of data at current position. This method is
required by the interface Iterator.
Returns
boolean whether there is a row of data at current position.
Implementation of
Iterator::valid()
|
Methods inherited from TComponent
__call(),
__destruct(),
__get(),
__isset(),
__set(),
__sleep(),
__unset(),
__wakeup(),
addParsedObject(),
asa(),
attachBehavior(),
attachBehaviors(),
attachClassBehavior(),
attachEventHandler(),
canGetProperty(),
canSetProperty(),
clearBehaviors(),
createdOnTemplate(),
detachBehavior(),
detachBehaviors(),
detachClassBehavior(),
detachEventHandler(),
disableBehavior(),
disableBehaviors(),
enableBehavior(),
enableBehaviors(),
evaluateExpression(),
evaluateStatements(),
fxAttachClassBehavior(),
fxDetachClassBehavior(),
getAutoGlobalListen(),
getBehaviorsEnabled(),
getClassHierarchy(),
getEventHandlers(),
getListeningToGlobalEvents(),
getSubProperty(),
hasEvent(),
hasEventHandler(),
hasProperty(),
isa(),
listen(),
raiseEvent(),
setSubProperty(),
unlisten()
|
|