DQL and SQL are different languages. Please check
http://www.doctrine-project.org/2010/03/29/doctrine2-custom-dql-udfs.html
for reference.

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On 9 December 2014 at 18:25, João Carlos Santa Ana <
[email protected]> wrote:

> a few hours of my life on it;
> SQL query in DB, it works:
>
>  SELECT date_format(`expiration_at`, '%m %Y') as 'date', `expiration_at`
> FROM `system_payment`;
>
> But, this is not:
>
>
>           $query = $this->getEntityManager()->createQueryBuilder()
>               ->select ("\DATE_FORMAT('p.expirationAt', '%m %y') as
> 'expirationAt'", 'p')
>               ->from('System\Entity\Payment', 'p');
> echo $query: //SELECT \DATE_FORMAT('p.expirationAt', '%m %y') as
> 'expirationAt', p FROM System\Entity\Payment p
>
> Do Ideas for solution?
>
>
>
>
>
>
> Em segunda-feira, 8 de dezembro de 2014 19h08min53s UTC-2, Marco Pivetta
> escreveu:
>>
>> new \DateTime('p.expirationAt', new \DateTimeZone('America/Sao_Paulo'))
>> is not a valid way to instantiate a DateTime object:
>> http://php.net/manual/en/class.datetime.php
>>
>> Marco Pivetta
>>
>> http://twitter.com/Ocramius
>>
>> http://ocramius.github.com/
>>
>> On 8 December 2014 at 19:28, João Carlos Santa Ana <[email protected]>
>> wrote:
>>
>>> This also does not work!!
>>>
>>>    $query = $this->getEntityManager()->createQueryBuilder()
>>>               ->select("\DATE_FORMAT('p.expirationAt', '%Y %m')", 'p')
>>>               ->from('System\Entity\Payment', 'p' );
>>>
>>>
>>> Em segunda-feira, 8 de dezembro de 2014 14h18min25s UTC-2, João Carlos
>>> Santa Ana escreveu:
>>>
>>>> Hi, can help please
>>>> Thanks
>>>>
>>>>
>>>>
>>>>  $query = $this->getEntityManager()->createQueryBuilder()
>>>>               ->select('p.expirationAt', 'p')
>>>>               ->from('System\Entity\Payment', 'p' )
>>>>               ->groupBy(\date_format(new \DateTime('p.expirationAt',
>>>> new \DateTimeZone('America/Sao_Paulo')), 'Y-m'));
>>>>
>>>>
>>>> Failed to parse time string (p.expirationAt) at position 8 (t): Double 
>>>> timezone specification
>>>>
>>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "doctrine-user" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/doctrine-user.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "doctrine-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/doctrine-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to