Prado\Data\SqlMap\Statements\TMappedStatement::runQueryForMap PHP 메소드

runQueryForMap() 공개 메소드

If valueProperty is null, the entire result object will be entered. This method should only be called by internal developers, consider using executeQueryForMap() first.
또한 보기: executeQueryForMap()
public runQueryForMap ( $connection, $parameter, $command, $keyProperty, $valueProperty = null, $delegate = null ) : array
리턴 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;
    }