php - Doctrine add columns from a subquery -
i have following code in sql:
select id, sum(horas) horas , sum(custo) custo from( select mr.name, mr.id id, sum(hour(timediff(m.end, m.start))) horas, sum(hour(timediff(m.end, m.start))) * u.cost_hour custo meeting m inner join meeting_join_rooms on m.id = meeting_join_rooms.meeting_id inner join meeting_rooms mr on meeting_join_rooms.meeting_room_id = mr.id inner join meeting_attendee ma on ma.meeting_id = m.id inner join users u on u.id = ma.user_id m.cancel = false , m.ismaster = false group mr.name, u.id ) subquery group name
i've converted code doctrine using following query builder:
$subquery = $this->getentitymanager() ->createquerybuilder() ->select(' mr.name name, sum(hour(timediff(m.end, m.start))) hours, sum(hour(timediff(m.end, m.start))) * users.costhour cost') ->from('appbundle:meeting','m') ->join('m.meetingrooms', 'mr') ->join('m.participantusers', 'ma') ->join('ma.user_id', 'users') ->join('users.groups', 'gu') ->where('m.cancel = false') ->andwhere('m.ismaster=false'); $totalhoursandcost = $this->getentitymanager()->createquerybuilder() ->select('sum(hours) y, sum(cost) totalcost') ->from( '## $subquery here ##') ->groupby('name')->getquery() ->getresult();
how sum columns result subquery in doctrine?
Comments
Post a Comment