This works for me.

$q = $this->createQuery('p')
  ->select('MAX(p.teid) as maxid');

 return $q->fetchOne()->maxid;

On 17 dub, 17:32, "NOOVEO - Christophe Brun" <c.b...@nooveo.fr> wrote:
> Hi Andrei,
> most unfortunately, it doesn't work either. My alias is still v__0 :o(
>
> ________________________________
>
> De : symfony-users@googlegroups.com [mailto:symfony-us...@googlegroups.com] 
> De la part de Andrei Dziahel
> Envoyé : samedi 17 avril 2010 17:08
> À : symfony-users@googlegroups.com
> Objet : Re: [symfony-users] Colum alias in an aggregate query / Doctrine
>
> hi.
>
> ->select('MAX(v.rang) AS max_rang, v.*') should do the job.
>
> Alias "is not set" because there's nothing to "attach" alias to. Because only 
> one column is fetched by SELECT - an aggregate column itself.
>
> 2010/4/17 NOOVEO - Christophe Brun <c.b...@nooveo.fr>
>
>         After the Doctrine 
> documentation,http://www.doctrine-project.org/documentation/manual/1_2/en/dql-doctr...
>         I'm trying a query like this :
>
>         $vp = Doctrine_Query::create()
>           ->select('MAX(v.rang) AS max_rang')
>           ->from('VitrineParagraphe v')
>           ->where('v.vitrine_id = ?', $vitrineId)
>           ->execute();
>
>         The executed query, is after the logs :
>         SELECT MAX(v.rang) AS v__0 FROM vitrine_paragraphe v WHERE 
> (v.vitrine_id = ?) - (17)
>
>         and of course, the further $vp->max_rang used to retrieve the desired 
> value fails.
>         Any ideas why the alias is not set ?
>
>         --
>         If you want to report a vulnerability issue on symfony, please send 
> it to security at symfony-project.com
>
>         You received this message because you are subscribed to the Google
>         Groups "symfony users" group.
>         To post to this group, send email to symfony-users@googlegroups.com
>         To unsubscribe from this group, send email to
>         symfony-users+unsubscr...@googlegroups.com 
> <mailto:symfony-users%2bunsubscr...@googlegroups.com>
>         For more options, visit this group at
>        http://groups.google.com/group/symfony-users?hl=en
>
> --
> With the best regards, Andrei.
>
> --
> If you want to report a vulnerability issue on symfony, please send it to 
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony users" group.
> To post to this group, send email to symfony-users@googlegroups.com
> To unsubscribe from this group, send email to
> symfony-users+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/symfony-users?hl=en
>
> --
> If you want to report a vulnerability issue on symfony, please send it to 
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony users" group.
> To post to this group, send email to symfony-users@googlegroups.com
> To unsubscribe from this group, send email to
> symfony-users+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/symfony-users?hl=en

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to