Prado\Data\SqlMap\Statements\TMappedStatement::runQueryForMap PHP Method

runQueryForMap() public method

If valueProperty is null, the entire result object will be entered. This method should only be called by internal developers, consider using executeQueryForMap() first.
See also: executeQueryForMap()
public runQueryForMap ( $connection, $parameter, $command, $keyProperty, $valueProperty = null, $delegate = null ) : array
return array An array of object containing the rows keyed by keyProperty.
    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;
    }