How to write UNION in Doctrine 2.0

后端 未结 4 959
清歌不尽
清歌不尽 2020-12-15 06:49

How to write this SQL query in Doctrine 2.0 (and fetch results)?

(SELECT \'group\' AS type, 
    CONCAT(u.firstname, \" \", u.surname) as fullname, 
    g.na         


        
4条回答
  •  难免孤独
    2020-12-15 07:22

    Well, I found maybe the best solution:

    /**
     * @Entity
     * @InheritanceType("JOINED")
     * @DiscriminatorColumn(name="discr", type="string")
     * @DiscriminatorMap({"group" = "NotificationGroup", "event" = "NotificationEvent"})
     */
    class Notification {
       // ...
    }
    

    And then two classes (NotificationGroup and NotificationEvent) extending Notification:

    /**
     * @Entity
     */
    class NotificationGroup extends Notification {
        //...
    }
    
    /**
     * @Entity
     */
    class NotificationEvent extends Notification {
        //...
    }
    

提交回复
热议问题