doctrine2 - Symfony Doctrine: Use of subquery with "HAVING" clause without using EXISTS -


in symfony project i'm trying make query calculated field. simplify lot sql that:

select o.id, (p.price_a + p.price_b) total_price objects o inner join prices p on o.id = p.object_id having total_price > 10 

my calculated field more complex , use external values change , cannot pre-calculate it.

as want distinct object.id i've added upper code subquery:

select distinct o_id  (   select o.id o_id, (p.price_a + p.price_b) total_price   object o   inner join price p   on o.id = p.object_id   having total_price > 10) 

in symfony want query returns distinct "object"s.

i've tried many options query builder cannot add subquery "from" clause.

i'm tryng avoid using inefficient exists clause:

select distinct o.id  objects o exists (   select p.*, (p.price_a + p.price_b) total_price   prices p   o.id = p.object_id   having total_price > 10) 

is there way query builder without using "exists"?

i've resolved problem hidden keyword. hidden can mark field avoid orm fetching. it's perfect remove calculated fields.

with dql:

select o, (p.price_a + p.price_b) hidden total_price testobjectbundle:object o inner join testobjectbuncle:price p group o having total_price > 10 

Comments