User Profile

Collapse

Profile Sidebar

Collapse
Xory
Xory
Last Activity: Sep 26 '12, 01:24 PM
Joined: Sep 17 '12
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Xory
    replied to GROUB BY problems-(Using ORM Doctrine-DQL)
    in PHP
    Ok, thanks anyway for all the help.
    See more | Go to post

    Leave a comment:


  • Xory
    replied to GROUB BY problems-(Using ORM Doctrine-DQL)
    in PHP
    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.
    See more | Go to post

    Leave a comment:


  • Xory
    replied to GROUB BY problems-(Using ORM Doctrine-DQL)
    in PHP
    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:...
    See more | Go to post
    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:


  • Xory
    replied to GROUB BY problems-(Using ORM Doctrine-DQL)
    in PHP
    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
    ...
    See more | Go to post
    Last edited by zmbd; Sep 19 '12, 07:58 PM. Reason: place code tags around SQL

    Leave a comment:


  • Xory
    replied to GROUB BY problems-(Using ORM Doctrine-DQL)
    in PHP
    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...
    See more | Go to post

    Leave a comment:


  • Xory
    started a topic GROUB BY problems-(Using ORM Doctrine-DQL)
    in PHP

    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
    ...
    See more | Go to post
    Last edited by zmbd; Sep 19 '12, 08:00 PM. Reason: placed SQL in code block
No activity results to display
Show More
Working...