public function mapLoadCriteriaToQuery(ILoadCriteria $criteria) : MappedLoadQuery
    {
        $select = $this->criteriaMapper->mapCriteriaToSelect($criteria, $memberMappings, $criteria->getAliasNestedMemberMap());
        $select->setColumns([]);

        $columnIndexMap  = [];
        $relationsToLoad = [];

        foreach ($criteria->getAliasNestedMemberMap() as $alias => $member) {
            /** @var MemberMappingWithTableAliases $memberMapping */
            $memberMapping = $memberMappings[$member->asString()];
            $mapping       = $memberMapping->getMapping();

            if ($mapping instanceof IFinalRelationMemberMapping) {
                $memberRelation   = $mapping->asMemberRelation();
                $parentTableAlias = $memberRelation instanceof ToManyMemberRelation || !($memberRelation->getFirstRelation() instanceof ISeparateTableRelation) || count($memberMapping->getTableAliases()) === 1
                    ? $memberMapping->getLastTableAlias()
                    : $memberMapping->getSecondLastTableAlias();
                $parentTable      = $select->getTableFromAlias($parentTableAlias);
                $parentColumnMap  = [];

                $parentColumnsToLoad = $memberRelation->getParentColumnsToLoad();

                if (!($mapping instanceof ToOneEmbeddedObjectMapping)) {
                    $parentColumnsToLoad[] = $parentTable->getPrimaryKeyColumnName();
                }

                foreach ($parentColumnsToLoad as $column) {
                    $parentColumnMap[$alias . '_' . $column] = $column;

                    $select->addColumn($alias . '_' . $column, Expr::column($parentTableAlias, $parentTable->getColumn($column)));
                }

                $relationsToLoad[$alias] = [$memberRelation, $parentTable, $parentColumnMap];
            } else {
                $mapping->addSelectColumn($select, $memberMapping->getLastTableAlias(), $alias);
                $columnIndexMap[$alias] = $alias;
            }
        }

        foreach ($memberMappings as $key => $memberMapping) {
            /** @var MemberMappingWithTableAliases $memberMapping */
            $memberMappings[$key] = $memberMapping->getMapping();
        }


        return new MappedLoadQuery($select, $columnIndexMap, $relationsToLoad);
    }
public function mapLoadCriteriaToQuery(ILoadCriteria $criteria) : MappedLoadQuery
    {
        $select = $this->criteriaMapper->mapCriteriaToSelect($criteria, $memberMappings, $criteria->getAliasNestedMemberMap());
        $select->setColumns([]);

        $columnIndexMap  = [];
        $relationsToLoad = [];

        foreach ($criteria->getAliasNestedMemberMap() as $alias => $member) {
            /** @var MemberMappingWithTableAliases $memberMapping */
            $memberMapping = $memberMappings[$member->asString()];
            $mapping       = $memberMapping->getMapping();

            if ($mapping instanceof IFinalRelationMemberMapping) {
                $memberRelation   = $mapping->asMemberRelation();
                $parentTableAlias = $memberRelation instanceof ToManyMemberRelation || !($memberRelation->getFirstRelation() instanceof ISeparateTableRelation) || count($memberMapping->getTableAliases()) === 1
                    ? $memberMapping->getLastTableAlias()
                    : $memberMapping->getSecondLastTableAlias();
                $parentTable      = $select->getTableFromAlias($parentTableAlias);
                $parentColumnMap  = [];

                $parentColumnsToLoad = $memberRelation->getParentColumnsToLoad();

                if (!($mapping instanceof ToOneEmbeddedObjectMapping)) {
                    $parentColumnsToLoad[] = $parentTable->getPrimaryKeyColumnName();
                }

                foreach ($parentColumnsToLoad as $column) {
                    $parentColumnMap[$alias . '_' . $column] = $column;

                    $select->addColumn($alias . '_' . $column, Expr::column($parentTableAlias, $parentTable->getColumn($column)));
                }

                $relationsToLoad[$alias] = [$memberRelation, $parentTable, $parentColumnMap];
            } else {
                $mapping->addSelectColumn($select, $memberMapping->getLastTableAlias(), $alias);
                $columnIndexMap[$alias] = $alias;
            }
        }

        foreach ($memberMappings as $key => $memberMapping) {
            /** @var MemberMappingWithTableAliases $memberMapping */
            $memberMappings[$key] = $memberMapping->getMapping();
        }


        return new MappedLoadQuery($select, $columnIndexMap, $relationsToLoad);
    }
public function mapLoadCriteriaToQuery ( ILoadCriteria $ criteria ) : MappedLoadQuery { $ select = $ this -> criteriaMapper -> mapCriteriaToSelect ( $ criteria , $ memberMappings , $ criteria -> getAliasNestedMemberMap ( ) ) ; $ select -> setColumns ( [ ] ) ; $ columnIndexMap = [ ] ; $ relationsToLoad = [ ] ; foreach ( $ criteria -> getAliasNestedMemberMap ( ) as $ alias => $ member ) { /** @var MemberMappingWithTableAliases $memberMapping */ $ memberMapping = $ memberMappings [ $ member -> asString ( ) ] ; $ mapping = $ memberMapping -> getMapping ( ) ; if ( $ mapping instanceof IFinalRelationMemberMapping ) { $ memberRelation = $ mapping -> asMemberRelation ( ) ; $ parentTableAlias = $ memberRelation instanceof ToManyMemberRelation || ! ( $ memberRelation -> getFirstRelation ( ) instanceof ISeparateTableRelation ) || count ( $ memberMapping -> getTableAliases ( ) ) === 1 ? $ memberMapping -> getLastTableAlias ( ) : $ memberMapping -> getSecondLastTableAlias ( ) ; $ parentTable = $ select -> getTableFromAlias ( $ parentTableAlias ) ; $ parentColumnMap = [ ] ; $ parentColumnsToLoad = $ memberRelation -> getParentColumnsToLoad ( ) ; if ( ! ( $ mapping instanceof ToOneEmbeddedObjectMapping ) ) { $ parentColumnsToLoad [ ] = $ parentTable -> getPrimaryKeyColumnName ( ) ; } foreach ( $ parentColumnsToLoad as $ column ) { $ parentColumnMap [ $ alias . '_' . $ column ] = $ column ; $ select -> addColumn ( $ alias . '_' . $ column , Expr :: column ( $ parentTableAlias , $ parentTable -> getColumn ( $ column ) ) ) ; } $ relationsToLoad [ $ alias ] = [ $ memberRelation , $ parentTable , $ parentColumnMap ] ; } else { $ mapping -> addSelectColumn ( $ select , $ memberMapping -> getLastTableAlias ( ) , $ alias ) ; $ columnIndexMap [ $ alias ] = $ alias ; } } foreach ( $ memberMappings as $ key => $ memberMapping ) { /** @var MemberMappingWithTableAliases $memberMapping */ $ memberMappings [ $ key ] = $ memberMapping -> getMapping ( ) ; } return new MappedLoadQuery ( $ select , $ columnIndexMap , $ relationsToLoad ) ; }
Maps the supplied criteria to a select query.

@param ILoadCriteria $criteria

@return MappedLoadQuery
Maps the supplied criteria to a select query .