protected function loadQuery(string $sql, array $parameters = []) : array
    {
        $sql   = $this->replaceQueryPlaceholders($sql);
        $query = $this->connection->prepare($sql, $parameters);
        $rows  = $query->execute()->getResults();

        if (empty($rows)) {
            return [];
        }

        $this->validateHasRequiredColumns($sql, reset($rows));

        $rowSet = $this->connection->getPlatform()->mapResultSetToPhpForm($this->mapper->getSelect()->getResultSetTableStructure(), $rows);

        return $this->mapper->loadAll($this->loadingContext, $rowSet->getRows());
    }
protected function loadQuery(string $sql, array $parameters = []) : array
    {
        $sql   = $this->replaceQueryPlaceholders($sql);
        $query = $this->connection->prepare($sql, $parameters);
        $rows  = $query->execute()->getResults();

        if (empty($rows)) {
            return [];
        }

        $this->validateHasRequiredColumns($sql, reset($rows));

        $rowSet = $this->connection->getPlatform()->mapResultSetToPhpForm($this->mapper->getSelect()->getResultSetTableStructure(), $rows);

        return $this->mapper->loadAll($this->loadingContext, $rowSet->getRows());
    }
protected function loadQuery ( string $ sql , array $ parameters = [ ] ) : array { $ sql = $ this -> replaceQueryPlaceholders ( $ sql ) ; $ query = $ this -> connection -> prepare ( $ sql , $ parameters ) ; $ rows = $ query -> execute ( ) -> getResults ( ) ; if ( empty ( $ rows ) ) { return [ ] ; } $ this -> validateHasRequiredColumns ( $ sql , reset ( $ rows ) ) ; $ rowSet = $ this -> connection -> getPlatform ( ) -> mapResultSetToPhpForm ( $ this -> mapper -> getSelect ( ) -> getResultSetTableStructure ( ) , $ rows ) ; return $ this -> mapper -> loadAll ( $ this -> loadingContext , $ rowSet -> getRows ( ) ) ; }
Loads an array of entities from the supplied sql query.

The the table name can be interpolated by the "(table)" placeholder
The required columns can be interpolated by using the "(columns)" placeholder

Example:
<code>
$entities = $this->loadRows(
'SELECT (columns) FROM (table) table_alias WHERE some_column > :param',
['param' => 10]
);
</code>

@param string $sql
@param array  $parameters

@return IEntity[]
Loads an array of entities from the supplied sql query .