I have made the following DQL call:
"SELECT SUBSTRING(e.sDateStart, 1, 4) as year
FROM contrastBundle:Exhibition e
WHERE e.sDateStart < :dateStart
GROUP BY year
ORDER BY year DESC"
which basically returns what I need but in the following form:
array(3) {
[0]=>
array(1) {
["year"]=>
string(4) "2007"
}
[1]=>
array(1) {
["year"]=>
string(4) "2006"
}
[2]=>
array(1) {
["year"]=>
string(4) "2005"
}
}
This makes it quite annoying to work with it.
EDIT In:
{% for eachyear in years %}
<a {% if year == eachyear.year %}class="active"{% endif %} href="{{path('exhibitions', {'year' : eachyear.year })}}">{{ eachyear.year }}</a>
{% endfor %}
I can access the strings with eachyear.year but is an ugly solution.
I was wondering which would be the best solution to this, i'd especially like to process the array i get from the call so that it is basically an array of years. pop_array() and similar don't seem to be helpful. I also tried to hydrate the output of the call, getArrayResult() and getScalarResult() will all return the same output.