KWeb  6.4
Collection_Query Class Reference

Data read from DB query result. More...

Inheritance diagram for Collection_Query:
Collection

Public Member Functions

 __construct (KDB_Driver $db, $result, $query=null, array $options=array())
 isCached ()
 Returns true if whole response is cached.
 isQueryExecuted ()
 Returns true if query was already executed.
 getQueryResult ()
 getDb ()
 getQuery ()
 setQuery ($query)
 Changes the query.
 count ()
 current ()
 next ()
 Moves to the next position.
 currentPosition ()
 Returns current position in the set.
 valid ()
 Returns item at current position, staying at the current position.
 hasField ($field)
 seek ($pos)
 close ()
 Closes the collection and frees up resources.
 isBidirectional ()
 Returns true if data can be traversed in both directions.
 prefetch ($limit=false, $start=false)
 Items will be prefetched (if needed) in a batch for later retrieval.

Data Fields

const OPT_QUERYOPTIONS = 'queryoptions'
 Options to pass to KDB::query.
 $requeryOnRewind = true
 As database reading is not bidirectional, it's impossible to go back in the results without caching.

Protected Attributes

 $db
 $result
 $query
 $position = 0
 $currentFetch = null
 $cached = array()
 $dataPosition = 0

Detailed Description

Data read from DB query result.


Constructor & Destructor Documentation

Collection_Query::__construct ( KDB_Driver db,
result,
query = null,
array $  options = array() 
)
Parameters:
$dbDatabase to read from. If null, $query object will be used to query the database when needed
$resultQuery result object. If null, $query object will be used to query the database when needed

Member Function Documentation

Collection_Query::close ( )

Closes the collection and frees up resources.

Reimplemented from Collection.

Collection_Query::count ( )
Collection_Query::current ( )
Collection_Query::currentPosition ( )

Returns current position in the set.

Reimplemented from Collection.

Collection_Query::getDb ( )
Returns:
KDB
Collection_Query::getQuery ( )
Returns:
SqlQueryBuilder
Collection_Query::getQueryResult ( )
Collection_Query::hasField ( field)
Returns:
boolean true if collection contains this field

Reimplemented from Collection.

Collection_Query::isBidirectional ( )

Returns true if data can be traversed in both directions.

Returns:
boolean

Reimplemented from Collection.

Collection_Query::isCached ( )

Returns true if whole response is cached.

Collection_Query::isQueryExecuted ( )

Returns true if query was already executed.

Collection_Query::next ( )

Moves to the next position.

Reimplemented from Collection.

Collection_Query::prefetch ( limit = false,
start = false 
)

Items will be prefetched (if needed) in a batch for later retrieval.

Parameters:
Numberof items to prefetch or false
Startof the prefetch or false for current position
Returns:
boolean TRUE if prefetch was successfull, FALSE if prefetch can't be supported

Reimplemented from Collection.

Collection_Query::seek ( pos)
Collection_Query::setQuery ( query)

Changes the query.

If the query was already executed, nothing will really happen.

Collection_Query::valid ( )

Returns item at current position, staying at the current position.

Returns true if there is data at current possition

Returns:
boolean

Reimplemented from Collection.


Field Documentation

Collection_Query::$cached = array() [protected]
Collection_Query::$currentFetch = null [protected]
Collection_Query::$dataPosition = 0 [protected]
Collection_Query::$db [protected]
Collection_Query::$position = 0 [protected]
Collection_Query::$query [protected]
Collection_Query::$requeryOnRewind = true

As database reading is not bidirectional, it's impossible to go back in the results without caching.

Therefore to go back in the results it's possible to run query once again. As it's a performance penalty, every time it happens a E_USER_NOTICE will be triggered.

Collection_Query::$result [protected]
const Collection_Query::OPT_QUERYOPTIONS = 'queryoptions'

Options to pass to KDB::query.


The documentation for this class was generated from the following file: