简体   繁体   中英

Symfony2 Doctrine oneToMany orderBy multiple columns

I have code (.yml) like this:

oneToMany:
        products:
            targetEntity: SMS\Bundle\SwiadczeniaPlatne\Domain\Zlecenie\Produkt
            mappedBy: zlecenie
            cascade: [persist, remove]
            indexBy: id
            orphanRemoval: true
            orderBy: { patient: ASC, contract: ASC }

Patient and contract are objects. I want sort products by patient.name and contract.name. How can I do this?

You have a wrong format:

oneToMany:
        products:
            targetEntity: SMS\Bundle\SwiadczeniaPlatne\Domain\Zlecenie\Produkt
            mappedBy: zlecenie
            cascade: [persist, remove]
            indexBy: id
            orphanRemoval: true
            orderBy: 
                patient: ASC
                contract: ASC

Bookmark this doctrine2 entity yaml reference gist: https://gist.github.com/mnapoli/3839501

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM