Is it possible to get data from the database like this?

Hello, there was such question, there is a table with two columns "key" and "value". The question arose whether in the sample to obtain a result like this?

array(
 'key' => 'value',
 'key' => 'value',
 'key' => 'value'
)

I know there is an index by but there is not in this form I still get the result, there will be an array value.
March 23rd 20 at 18:55
1 answer
March 23rd 20 at 18:57
If I understand correctly the problem, you need to hydrate in the desired format.

Can you specify the type of hydration $query->getResult(Query::HYDRATE_SCALAR) ?
You can also make a custom Hydrator

Generally it is strange that there is an array there must be an object of TC Query::HYDRATE_OBJECT is by default, you do not accidentally put Query::HYDRATE_ARRAY, can been copied code from somewhere with this value ?

Delve into the possibilities: Doctrine 2: Hydration Modes
Yes I have HYDRATE_ARRAY, because as a result I need an array, not an object, but the campaign will always give an array with arrays, I try to look yet but, the result I would just like table, key => value and nothing more. - Adolfo commented on March 23rd 20 at 19:00
@Adolfo,
I would just like table, key => value

under the value that you see? If performance/field, you need HYDRATE_SCALAR - Hans62 commented on March 23rd 20 at 19:03
try to look for more

you would have said :--) if you do not fit the desired Hydrator -- you can make your wrote the same above
you are sure to find points of understanding, maybe not everything is clear in your question, e.g. how are you collecting the query, then offer to do it right - Hans62 commented on March 23rd 20 at 19:06

Find more questions by tags Symfony