$darkmode

| Qore TableMapper Module Reference 1.3

Public Member Functions | Protected Attributes | List of all members
TableMapper::SqlStatementMapperIterator Class Reference

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

Inherits Mapper::AbstractMapperIterator.

## Public Member Functions
| constructor (Qore::SQL::AbstractSQLStatement stmt, hash< auto > mapv, *hash< auto > opts)
| creates the iterator from the arguments passed More...
| constructor (SqlUtil::AbstractTable table, hash< auto > sh, hash< auto > mapv, *hash< auto > opts)
| creates the iterator from the arguments passed More...
| constructor (SqlUtil::Table table, hash< auto > sh, hash< auto > mapv, *hash< auto > opts)
| creates the iterator from the arguments passed More...
| constructor (TableMapper::AbstractSqlStatementOutboundMapper mapper)
| creates the iterator from the Mapper passed More...
int | getCount ()
| returns the internal record count More...
auto | getRuntime (string key)
| get current runtime option value for a key More...
hash< auto > | getValue ()
| returns the current row transformed with the mapper
bool | hasBulk ()
| returns True because this class supports bulk mode
list< auto > | mapBulk (int size)
| performs bulk mapping by selecting the requested number of rows in a single select More...
| replaceRuntime (*hash< auto > runtime)
| replaces runtime options More...
| resetCount ()
| resets the internal record count More...
| setRuntime (hash< auto > runtime)
| adds runtime options to the current runtime option hash More...
| setRuntime (string key, auto value)
| set the runtime option with "key" to value "value" More...

## Protected 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:

- hasBulk() returns True
- mapBulk() fetches the number of rows requested and then maps to output values

## Member Function Documentation

## ◆ constructor() [1/4]

TableMapper::SqlStatementMapperIterator::constructor | ( | Qore::SQL::AbstractSQLStatement | stmt,
|  | hash< auto > | mapv,
|  | *hash< auto > | opts
| ) |  |

creates the iterator from the arguments passed

Parameters

  stmt | already constructed SQLStatement object
  mapv | the mapper to transform the data
  opts | an optional hash of options for the mapper; see mapperoptions for a description of valid mapper options

## ◆ constructor() [2/4]

TableMapper::SqlStatementMapperIterator::constructor | ( | SqlUtil::AbstractTable | table,
|  | hash< auto > | sh,
|  | hash< auto > | mapv,
|  | *hash< auto > | opts
| ) |  |

creates the iterator from the arguments passed

Parameters

  table | SqlUtil::AbstractTable as a base for select hash `sh`
  sh | a SqlUtil select hash (columns/joins/wheres...)
  mapv | a 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 mapperkeys for detailed documentation for this option
  opts | an optional hash of options for the mapper; see mapperoptions for a description of valid mapper options

Exceptions

  MAP-ERROR | the map hash has a logical error (ex: `"trunc"` key given without `"maxlen"`, invalid map key)

## ◆ constructor() [3/4]

TableMapper::SqlStatementMapperIterator::constructor | ( | SqlUtil::Table | table,
|  | hash< auto > | sh,
|  | hash< auto > | mapv,
|  | *hash< auto > | opts
| ) |  |

creates the iterator from the arguments passed

Parameters

  table | SqlUtil::Table as a base for select hash `sh`
  sh | a SqlUtil select hash (columns/joins/wheres...)
  mapv | a 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 mapperkeys for detailed documentation for this option
  opts | an optional hash of options for the mapper; see mapperoptions for a description of valid mapper options

Exceptions

  MAP-ERROR | the map hash has a logical error (ex: `"trunc"` key given without `"maxlen"`, invalid map key)

## ◆ constructor() [4/4]

TableMapper::SqlStatementMapperIterator::constructor | ( | TableMapper::AbstractSqlStatementOutboundMapper | mapper | ) |

creates the iterator from the Mapper passed

Parameters

  mapper | the mapper to iterate

## ◆ getCount()

int TableMapper::SqlStatementMapperIterator::getCount | ( |  | ) |

returns the internal record count

See also
  resetCount()

## ◆ getRuntime()

auto TableMapper::SqlStatementMapperIterator::getRuntime | ( | string | key | ) |

get current runtime option value for a key

Parameters

  key | the runtime option key

Returns
  a runtime value if the key exists in the current runtime option hash and is set

See also
  - mapper_runtime_handling
  - replaceRuntime()
  - setRuntime()

Since
  TableMapper 1.1.1

## ◆ mapBulk()

list< auto > TableMapper::SqlStatementMapperIterator::mapBulk | ( | int | size | ) |

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

Parameters

  size | the 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

## ◆ replaceRuntime()

TableMapper::SqlStatementMapperIterator::replaceRuntime | ( | *hash< auto > | runtime | ) |

replaces runtime options

Parameters

  runtime | a hash of runtime options to use to replace the current runtime option hash

See also
  - mapper_runtime_handling
  - getRuntime()
  - setRuntime()

Since
  TableMapper 1.1

## ◆ resetCount()

TableMapper::SqlStatementMapperIterator::resetCount | ( |  | ) |

resets the internal record count

See also
  getCount()

## ◆ setRuntime() [1/2]

TableMapper::SqlStatementMapperIterator::setRuntime | ( | hash< auto > | runtime | ) |

adds runtime options to the current runtime option hash

Parameters

  runtime | a hash of runtime options to add to the current runtime option hash

See also
  - mapper_runtime_handling
  - replaceRuntime()
  - getRuntime()

Since
  TableMapper 1.1.1

## ◆ setRuntime() [2/2]

TableMapper::SqlStatementMapperIterator::setRuntime | ( | string | key,
|  | auto | value
| ) |  |

set the runtime option with "key" to value "value"

Parameters

  key | a string with valid runtime key
  value | anything passed to the current runtime `key`

See also
  - mapper_runtime_handling
  - replaceRuntime()
  - getRuntime()

Since
  TableMapper 1.1.1