public function runQueryForMap($connection, $parameter, $command, $keyProperty, $valueProperty = null, $delegate = null)
{
$map = array();
//$recordSet = $this->executeSQLQuery($connection, $sql);
$connection->setActive(true);
$reader = $command->query();
if ($delegate !== null) {
//while($row = $recordSet->fetchRow())
foreach ($reader as $row) {
$obj = $this->applyResultMap($row);
$key = TPropertyAccess::get($obj, $keyProperty);
$value = $valueProperty === null ? $obj : TPropertyAccess::get($obj, $valueProperty);
$param = new TResultSetMapItemParameter($key, $value, $parameter, $map);
$this->raiseRowDelegate($delegate, $param);
}
} else {
//while($row = $recordSet->fetchRow())
foreach ($reader as $row) {
$obj = $this->applyResultMap($row);
$key = TPropertyAccess::get($obj, $keyProperty);
$map[$key] = $valueProperty === null ? $obj : TPropertyAccess::get($obj, $valueProperty);
}
}
$this->onExecuteQuery($command);
return $map;
}