Skip to content

How to Select from Spec::join #205

@Daisuke-sama

Description

@Daisuke-sama

I have such a code

        $res = $this->getVehicleRepo()->getQueryBuilder(
            Spec::andX(
                Spec::select('model'),
                new IsNotSold(),

                new JoinModelModifier(),
                new ModelsBelongToMaker($makerId)
            )
        );

I'm going to select fields from the Model table, which is joined by new JoinModelModifier(), while all the selections are performed for the root alias, which comes from the ->getVehicleRepo, i.e. the Vehicle table.
Can't understand how to select such a data, except for doing two separate queries on both repos.

By the way with the classic doctrine I can achieve the desirable with

        $res = $this->getNotSoldVehicleQueryBuilder()
            ->select('(v.model)')
            ->addSelect('m.name')
            ->addSelect('m.id')
            ->join('v.model', 'm')
            ->join('m.maker', 'mk')
            ->andWhere('mk.id = :maker_id')
            ->setParameter('maker_id', $makerId)
            ->groupBy('v.model');

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions