PRADO Component Framework for PHP 5
  • Home
  • About
  • Testimonials
  • Demos
  • Download
  • Documentation
  • Forum
  • Development
  • Tutorials
  • Class Docs
  • API Manual
  • Wiki

Packages

  • None
  • System
    • Caching
    • Collections
    • Data
      • ActiveRecord
        • Relations
        • Scaffold
          • InputBuilder
      • Commom
        • Sqlite
      • Common
        • Mssql
        • Mysql
        • Oracle
        • Pgsql
        • Sqlite
      • DataGateway
      • SqlMap
        • Configuration
        • Statements
    • Exceptions
    • I18N
    • IO
    • Security
    • Util
    • Web
      • Javascripts
      • Services
      • UI
        • ActiveControls
        • WebControls
    • Xml
  • Wsat
    • pages
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

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)
    // $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 setFetchMode FetchMode. See http://www.php.net/manual/en/function.PDOStatement-setFetchMode.php for more details.

TComponent
Extended by TDbDataReader implements Iterator
Package: System\Data
Copyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 3.0
Located at Data/TDbDataReader.php
Methods summary
public
# __construct( TDbCommand $command )

Constructor.

Constructor.

Parameters

$command
TDbCommand
the command generating the query result

Overrides

TComponent::__construct()
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

http://www.php.net/manual/en/function.PDOStatement-bindColumn.php
public
# setFetchMode( mixed $mode )

See

http://www.php.net/manual/en/function.PDOStatement-setFetchMode.php
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

TDbException
if this method is invoked twice

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()
Constants inherited from TComponent
GLOBAL_RAISE_EVENT_LISTENER
Terms of Service | Contact Us
PRADO v3.2.4 API Manual API documentation generated by ApiGen 2.8.0
Copyright © 2006-2014 by the PRADO Group.
Powered by PRADO