T
T
Tarakkolya2014-07-01 18:45:06
Doctrine ORM
Tarakkolya, 2014-07-01 18:45:06

How to get the first letter of a string field using DQL ?

How to get the first letter of a string field using DQL ? I tried using the LEFT([field],1) function, but it gives an error.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Hudinsky, 2015-02-10
@myLizzarD

Assumptions:
- the doctrine does not understand such a function. You can solve the problem like this
- if you call getResult on the received query, then in any case you will get an error, because the doctrine does not know which field to map the result to. To do this, you need to change
to
and call not getResult, but getArrayResult, for example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question