public function runQueryForList($connection, $parameter, $sql, $result, $delegate = null)
{
$registry = $this->getManager()->getTypeHandlers();
$list = $result instanceof \ArrayAccess ? $result : $this->_statement->createInstanceOfListClass($registry);
$connection->setActive(true);
$reader = $sql->query();
//$reader = $this->executeSQLQueryLimit($connection, $sql, $max, $skip);
if ($delegate !== null) {
foreach ($reader as $row) {
$obj = $this->applyResultMap($row);
$param = new TResultSetListItemParameter($obj, $parameter, $list);
$this->raiseRowDelegate($delegate, $param);
}
} else {
//var_dump($sql,$parameter);
foreach ($reader as $row) {
// var_dump($row);
$list[] = $this->applyResultMap($row);
}
}
if (!$this->_groupBy->isEmpty()) {
$list = $this->_groupBy->collect();
$this->initialGroupByResults();
}
$this->executePostSelect($connection);
$this->onExecuteQuery($sql);
return $list;
}