Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CDbCommand
  • CDbConnection
  • CDbDataReader
  • CDbMigration
  • CDbTransaction

Exceptions

  • CDbException
  • Overview
  • Package
  • Class
  • Tree

Class CDbDataReader

CDbDataReader represents a forward-only stream of rows from a query result set.

To read the current row of data, call CDbDataReader::read(). The method CDbDataReader::readAll() returns all the rows in a single array.

One can also retrieve the rows of data in CDbDataReader by using foreach:

foreach($reader as $row)
    // $row represents a row of data

Since CDbDataReader 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.

CComponent
Extended by CDbDataReader implements Iterator, Countable
Package: system\db
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/db/CDbDataReader.php
Methods summary
public
# __construct( CDbCommand $command )

Constructor.

Constructor.

Parameters

$command
CDbCommand
$command the command generating the query result
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
$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.
$value
mixed
$value Name of the PHP variable to which the column will be bound.
$dataType
integer
$dataType Data type of the parameter

See

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

Set the default fetch mode for this statement

Set the default fetch mode for this statement

Parameters

$mode
mixed
$mode fetch 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
$columnIndex 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 an object populated with the next row of data.

Returns an object populated with the next row of data.

Parameters

$className
string
$className class name of the object to be created and populated
$fields
array
$fields Elements of this array are passed to the constructor

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 boolean
# 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.

Returns

boolean
Returns true on success or false on failure.
public
# close( )

Closes the reader. This frees up the resources allocated for executing this SQL statement. Read attempts after this method call are unpredictable.

Closes the reader. This frees up the resources allocated for executing this SQL statement. Read attempts after this method call are unpredictable.

public boolean
# getIsClosed( )

whether the reader is closed or not.

whether the reader is closed or not.

Returns

boolean
whether the reader is closed or not.
public integer
# getRowCount( )

Returns the number of rows in the result set. Note, most DBMS may not give a meaningful count. In this case, use "SELECT COUNT(*) FROM tableName" to obtain the number of rows.

Returns the number of rows in the result set. Note, most DBMS may not give a meaningful count. In this case, use "SELECT COUNT(*) FROM tableName" to obtain the number of rows.

Returns

integer
number of rows contained in the result.
public integer
# count( )

Returns the number of rows in the result set. This method is required by the Countable interface. Note, most DBMS may not give a meaningful count. In this case, use "SELECT COUNT(*) FROM tableName" to obtain the number of rows.

Returns the number of rows in the result set. This method is required by the Countable interface. Note, most DBMS may not give a meaningful count. In this case, use "SELECT COUNT(*) FROM tableName" to obtain the number of rows.

Returns

integer
number of rows contained in the result.

Implementation of

Countable::count()
public integer
# getColumnCount( )

Returns the number of columns in the result set. Note, even there's no row in the reader, this still gives correct column number.

Returns the number of columns in the result set. Note, even there's no row in the reader, this still gives correct column number.

Returns

integer
the number of columns in the result set.
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

CException
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 CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Magic properties summary
public boolean $isClosed
#

Whether the reader is closed or not.

Whether the reader is closed or not.

public integer $rowCount
#

Number of rows contained in the result.

Number of rows contained in the result.

public integer $columnCount
#

The number of columns in the result set.

The number of columns in the result set.

public mixed $fetchMode
#

Fetch mode.

Fetch mode.

API documentation generated by ApiGen 2.8.0