I already asked this question on stackoverflow, but because I am a little 
in a hurry, I figured I might get an answer more quickly here.

I have the fields *firstname* and *lastname* in my MySQL table. For 
convenience, I want to add a computed column to my Doctrine 2 entity called 
*full_name*. In plain old MySQL I would do something like this

SELECT CONCAT(firstname, " ", lastname) AS full_name FROM customers;

However, concatenating fields and constant strings (" " in this case) seems 
not to work with Doctrine's implementation of CONCAT. When using the 
following code

$repository
    ->createQueryBuilder('customer')
    ->select('CONCAT(customer.firstname, " ", customer.lastname) AS 
full_name') 
    // ...

I get the error

[Syntax Error] line 0, col 91: Error: Expected StateFieldPathExpression | 
string | InputParameter | FunctionsReturningStrings | AggregateExpression, 
got '"'

How can I achieve the same behavior as in MySQL? Does DQL implement a 
different operator für concatenation of strings besides the *CONCAT* function 
like 
some other SQL dialects do?

-- 
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 https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to