Answer the question
In order to leave comments, you need to log in
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 = new Query\ResultSetMapping();
$rsm->addEntityResult('Game\ServerBundle\Entity\Server\Server', 's');
$rsm->addFieldResult('s', 'id', 'id');
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question