S
S
senpay12015-09-29 17:53:10
symfony
senpay1, 2015-09-29 17:53:10

UnderfinedIndex ResultSetMapping how to define an alias here?

I make the following NativeSQL query:

SELECT *, @C := @C + 1  AS `top` FROM
            (
                SELECT *, @C := 0 FROM
                (
                    SELECT * FROM
                    (
                        SELECT s.*, s2.priority AS `priority` FROM `server` s
                            LEFT JOIN servers_services ss ON (s.id = ss.server_id)
                            LEFT JOIN service s2 ON (s2.id = ss.service_id)
                        WHERE s.is_banned = 0 AND s.is_vip = 1 AND ss.service_id IS NOT NULL
                        ORDER BY priority DESC
                    ) server_with_vip_with_services
 
                    UNION
 
                    SELECT * FROM
                    (
                        SELECT s.*, s2.priority AS `priority` FROM `server` s
                            LEFT JOIN servers_services ss ON (s.id = ss.server_id)
                            LEFT JOIN service s2 ON (s2.id = ss.service_id)
                        WHERE s.is_banned = 0 AND s.is_vip = 0 AND ss.service_id IS NOT NULL
                        ORDER BY priority DESC
                    ) server_without_vip_with_services

............

RSM:
$rsm = new Query\ResultSetMapping();
        $rsm->addEntityResult('Game\ServerBundle\Entity\Server\Server', 's');
        $rsm->addFieldResult('s', 'id', 'id');

Result:

Notice: Undefined index: id
500 Internal Server Error - ContextErrorException

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question