I'd like to display some rows of data from a database table. I'm keen to get some advice on how to best achieve this.
Let me explain how I do it now and why this question has been raised: I currently have a scheme whereby the controller loads data into an array, and then passes this to the twig template. The twig template then calls a "utility" controller to display the array. The utility controller takes care of formatting the fields, etc. So, for example:
Controller:
$cols = array('1','2','3');
$rows = array();
for (...) {
$rows[] = ...
}
return array(
'cols' => $cols,
'rows' => $rows,
);
Twig:
{% render 'Bundle:Table:print' with { 'cols': cols, 'rows': rows } %}
However, when I tried to move to Symfony 2.2, I ran into a few problems because of the way that internal calls are now handled in 2.2. See http://symfony.com/blog/new-in-symfony-2-2-the-new-fragment-sub-framework
It looks like the arrays are converted to URL parameters, and then parsed out again (using parse_str). This lead to two distinct problems:
- For larger tables, PHP was limited to 1000 items in the arrays. (Yes, I can increase the limit, but is that sensible?)
- DateTime types seemed to lose their typing and were seen as just arrays.
So, is my original approach workable going forward? If not, what approach should be used?
Thanks.