Qore TableMapper Module Reference  1.1
TableMapper::SqlStatementMapperIterator Class Reference

provides a hash iterator based on a mapper object and an SQLStatement or SqlUtil select hash More...

Inheritance diagram for TableMapper::SqlStatementMapperIterator:

Public Member Functions

 constructor (SqlUtil::AbstractTable table, hash sh, hash mapv, *hash opts)
 creates the iterator from the arguments passed More...
 
 constructor (SqlUtil::Table table, hash sh, hash mapv, *hash opts)
 creates the iterator from the arguments passed More...
 
 constructor (Qore::SQL::SQLStatement stmt, hash mapv, *hash opts)
 creates the iterator from the arguments passed More...
 
int getCount ()
 returns the internal record count More...
 
hash getValue ()
 returns the current row transformed with the mapper
 
bool hasBulk ()
 returns True because this class supports bulk mode
 
list mapBulk (int size)
 performs bulk mapping by selecting the requested number of rows in a single select More...
 
 resetCount ()
 resets the internal record count More...
 

Private Attributes

Mapper::Mapper m_mapper
 data mapper
 

Detailed Description

provides a hash iterator based on a mapper object and an SQLStatement or SqlUtil select hash

provides support for bulk DML:

Member Function Documentation

TableMapper::SqlStatementMapperIterator::constructor ( SqlUtil::AbstractTable  table,
hash  sh,
hash  mapv,
*hash  opts 
)

creates the iterator from the arguments passed

Parameters
tableSqlUtil::AbstractTable as a base for select hash sh
sha SqlUtil select hash (columns/joins/wheres...)
mapva hash providing field mappings; each hash key is the name of the output field; each value is either True (meaning no translations are done; the data is copied 1:1) or a hash describing the mapping; see Mapper Specification Format for detailed documentation for this option
optsan optional hash of options for the mapper; see Mapper Options for a description of valid mapper options
Exceptions
MAP-ERRORthe map hash has a logical error (ex: "trunc" key given without "maxlen", invalid map key)
TableMapper::SqlStatementMapperIterator::constructor ( SqlUtil::Table  table,
hash  sh,
hash  mapv,
*hash  opts 
)

creates the iterator from the arguments passed

Parameters
tableSqlUtil::Table as a base for select hash sh
sha SqlUtil select hash (columns/joins/wheres...)
mapva hash providing field mappings; each hash key is the name of the output field; each value is either True (meaning no translations are done; the data is copied 1:1) or a hash describing the mapping; see Mapper Specification Format for detailed documentation for this option
optsan optional hash of options for the mapper; see Mapper Options for a description of valid mapper options
Exceptions
MAP-ERRORthe map hash has a logical error (ex: "trunc" key given without "maxlen", invalid map key)
TableMapper::SqlStatementMapperIterator::constructor ( Qore::SQL::SQLStatement  stmt,
hash  mapv,
*hash  opts 
)

creates the iterator from the arguments passed

Parameters
stmtalready constructed SQLStatement object
mapvthe mapper to transform the data
optsan optional hash of options for the mapper; see Mapper Options for a description of valid mapper options
int TableMapper::SqlStatementMapperIterator::getCount ( )

returns the internal record count

See also
resetCount()
list TableMapper::SqlStatementMapperIterator::mapBulk ( int  size)

performs bulk mapping by selecting the requested number of rows in a single select

Parameters
sizethe number of rows to return
Returns
a list of mapped hashes with a maximum number of rows corresponding to the size argument; in case there is less input data than requested, the list returned could have fewer rows than requested; in case there is no more data, the return value is an empty list
TableMapper::SqlStatementMapperIterator::resetCount ( )

resets the internal record count

See also
getCount()