GergelyPolonkai
GergelyPolonkai

Reputation: 6421

Doctrine 2 ORDER BY the field of a joinTable

I have an Entity defined like this:

Munkatars:
    id:
        id:
            type: integer
    fields:
        nev:
            type: text
        [...]
    manyToOne:
        vezeto:
            targetEntity: Munkatars
            inversedBy: alarendeltek
    oneToMany:
        alarendeltek:
            targetEntity: Munkatars
            mappedBy: vezeto
            fetch: EXTRA_LAZY

Is there a way to create a query that orders these Munkatars objects by their vezeto's nev field?

I've tried ORDER BY m.vezeto.nev, but that gave me an error, and the documentation didn't give much information on this.

Upvotes: 0

Views: 1294

Answers (1)

a.aitboudad
a.aitboudad

Reputation: 4092

you must use join like this example:

createQuery("SELECT m.nev 
             FROM  Entity\Munkatars as m 
             LEFT JOIN m.vezeto as v
             ORDER BY v.nev");

Upvotes: 2

Related Questions