- Home
- About
- Testimonials
- Demos
- Download
- Documentation
- Blogs
- Forum
- Support

Packages: default System System.Caching System.Collections System.Data System.Data.ActiveRecord System.Data.ActiveRecord.Relations System.Data.ActiveRecord.Scaffold System.Data.ActiveReecord.Scaffold.InputBuilder System.Data.Commom.Sqlite System.Data.Common System.Data.Common.Mssql System.Data.Common.Mysql System.Data.Common.Oracle System.Data.Common.Pgsql System.Data.Common.Sqlite System.Data.DataGateway System.Data.SqlMap System.Data.SqlMap.Configuration System.Data.SqlMap.Statements System.Exceptions System.I18N System.IO System.Security System.Util System.Web System.Web.Services System.Web.UI System.Web.UI.ActiveControls System.Web.UI.WebControls System.Web.UI.WebControls.assets System.Xml Classes: TDataSourceConfig TDbColumnCaseMode TDbCommand TDbConnection TDbDataReader TDbNullConversionMode TDbTransaction |
Keyword
# Class TDbDataReader
    TComponent
       |
       --TDbDataReader
TDbDataReader class. TDbDataReader represents a forward-only stream of rows from a query result set. To read the current row of data, call read. The method 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 FetchMode. See http://www.php.net/manual/en/function.PDOStatement-setFetchMode.php for more details. Since: 3.0 Author: Qiang Xue <qiang.xue@gmail.com>
Constructor Summary
public | __construct Array Constructor.
Method Summary
void | bindColumn ( mixed $column, mixed &$value, int $dataType) Binds a column to a PHP variable.
void | close () Closes the reader.
mixed | current () Returns the current row.
int | getColumnCount ()
boolean | getIsClosed ()
int | getRowCount ()
integer | key () Returns the index of the current row.
void | next () Moves the internal pointer to the next row.
void | nextResult () Advances the reader to the next result when reading the results of a batch of statements.
array|false | read () Advances the reader to the next row in a result set.
array | readAll () Reads the whole result set into an array.
mixed|false | readColumn ( int $columnIndex) Returns a single column from the next row of a result set.
mixed|false | readObject ( string $className, array $fields) Returns a single column from the next row of a result set.
void | rewind () Resets the iterator to the initial state.
void | setFetchMode ( mixed $mode)
boolean | valid () Returns whether there is a row of data at current position.
Methods Inherited From TComponent
TComponent::addParsedObject(), TComponent::attachEventHandler(), TComponent::canGetProperty(), TComponent::canSetProperty(), TComponent::createdOnTemplate(), TComponent::detachEventHandler(), TComponent::evaluateExpression(), TComponent::evaluateStatements(), TComponent::getEventHandlers(), TComponent::getSubProperty(), TComponent::hasEvent(), TComponent::hasEventHandler(), TComponent::hasProperty(), TComponent::raiseEvent(), TComponent::setSubProperty(), TComponent::__get(), TComponent::__set()
Constructor Details
## __construct
public __construct | Array
Constructor.
Method Details
## bindColumn
public void bindColumn | (mixed $column , mixed &$value , int $dataType )
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.
Input
mixed | $column | 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.
mixed | &$value | Name of the PHP variable to which the column will be bound.
int | $dataType | Data type of the parameter
Output
Exception
## close
public void close | ()
Closes the reader. Any further data reading will result in an exception.
Output
Exception
## current
public mixed current | ()
Returns the current row. This method is required by the interface Iterator.
Output
mixed | the current row.
Exception
## getColumnCount
public int getColumnCount | ()
Output
int | the number of columns in the result set. Note, even there's no row in the reader, this still gives correct column number.
Exception
## getIsClosed
public boolean getIsClosed | ()
Output
boolean | whether the reader is closed or not.
Exception
## getRowCount
public int getRowCount | ()
Output
int | 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.
Exception
## key
public integer key | ()
Returns the index of the current row. This method is required by the interface Iterator.
Output
integer | the index of the current row.
Exception
## next
public void next | ()
Moves the internal pointer to the next row. This method is required by the interface Iterator.
Output
Exception
## nextResult
public void 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.
Output
Exception
## read
public array|false read | ()
Advances the reader to the next row in a result set.
Output
array|false | the current row, false if no more row available
Exception
## readAll
public array readAll | ()
Reads the whole result set into an array.
Output
array | the result set (each array element represents a row of data). An empty array will be returned if the result contains no row.
Exception
## readColumn
public mixed|false readColumn | (int $columnIndex )
Returns a single column from the next row of a result set.
Input
int | $columnIndex | zero-based column index
Output
mixed|false | the column of the current row, false if no more row available
Exception
## readObject
public mixed|false readObject | (string $className , array $fields )
Returns a single column from the next row of a result set.
Input
string | $className | class name of the object to be created and populated
array | $fields | list of column names whose values are to be passed as parameters in the constructor of the class being created
Output
mixed|false | the populated object, false if no more row of data available
Exception
## rewind
public void rewind | ()
Resets the iterator to the initial state. This method is required by the interface Iterator.
Output
Exception
throws | TDbException if this method is invoked twice
## setFetchMode
public void setFetchMode | (mixed $mode )
Input
mixed | $mode |
Output
Exception
## valid
public boolean valid | ()
Returns whether there is a row of data at current position. This method is required by the interface Iterator.
Output
boolean | whether there is a row of data at current position.
Exception