User Profile
Collapse
-
Ok, thanks anyway for all the help. -
I tried that code and it's giving me this error
[Semantical Error] line 0, col -1 near 'SELECT s, c,': Error: Cannot select entity through identification variables without choosing at least one root entity alias.
I even tried to add the root entity alias, but... didn't work out.Leave a comment:
-
Well I've tried but it's not that simple... The query I sent you works just fine in native SQL, but when I try to do it in DQL I can't use something like e.estudiante_id 'cause even when that's a field of the evaluacion table it's not an attribute of the class 'Evaluacion'. The class 'Evaluacion' has an attribute estudiante which is an object of the class 'Estudiante' and it happen the same with the attribute clase. I did something like this:...Last edited by zmbd; Sep 19 '12, 09:11 PM. Reason: Please select your code or SQL and click on the <CODE/> format button when posting such. Thnx.Leave a comment:
-
Yes, I know what you mean, but I can't group by the id of the entity. A student (estudiante), might have several evaluations in one class (clase), that's why I need the average of those evaluations. If I do a group by the id of the table evaluacion I won't be able to get the information I need. This is the query in native SQL that I need to do in DQL:
...Code:SELECT estudiante_id, clase_id, AVG(evaluacion) FROM public.evaluacion GROUP
Leave a comment:
-
Well I know in SQL that's the way to do it, but here's an example from the Doctrine official documentation:
SELECT u, count(g.id) FROM Entities\User u JOIN u.groups g GROUP BY u.id
as you can see u is an object of the entity user and u is not entirely in the group by clause. I did the same I want to select the entity Evaluacion grouping by the fields estudiante and clase. I also use an aggregate function AVG to find the average of an...Leave a comment:
-
GROUB BY problems-(Using ORM Doctrine-DQL)
Hi, English is not my native language, so please excuse my redaction.
I´m using the php framework: Symfony 2, with Doctrine.
I´m doing the next query:
->...Code:createQuery('SELECT e, count(e.id) FROM Registro\RegistroBundle\Entity\Evaluacion e JOIN e.estudiante s JOIN e.clase c JOIN e.tipo_evaluacion t WHERE e.tipo_evaluacion = 1 AND s.grupo = 1 GROUP BY s.id, c
No activity results to display
Show More
Leave a comment: