Doctrine2 - How can I order by a discriminator column?

后端 未结 3 1586
攒了一身酷
攒了一身酷 2021-02-13 04:36

How should I go about ordering by a discriminator column in a doctrine repository query?

I have a pretty straight forward setup, I have different types of payment detai

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-13 05:02

    Can your try to use TYPE() or INSTANCE OF?

    related: https://groups.google.com/forum/#!topic/doctrine-user/JtCbwuN-37o

    However, this topic doesn't say if it is implemented or not. At the time it was written someone said order by wouldn't work.

    $dql = 'SELECT pd
            from
            AccountingBundle:PaymentDetail pd
            JOIN ClientProductBundle:ClientProduct cp
            WITH cp.payment_detail_id = pd.id
            WHERE
            cp.payment_detail_id = pd.id
            and cp.client_contact_id = :client_contact_id
            GROUP BY pd.id
            ORDER BY TYPE(pd)';
    

提交回复
热议问题