Wondering if I can (or should try to) use a partialLoop in this scenario.
In my Zend_View, I have an array of data from a table, like so:
// parents
Array
(
[0] => stdClass Object
(
[id] => 73622
[datef] => Mon 18-Apr-2011
[timef] => 10:00
[type] => conference
[judge] => Berman
[language] => Spanish
[place] => 14A
)
[1] => stdClass Object
(
[id] => 73770
[datef] => Mon 18-Apr-2011
[timef] => 10:20
[type] => vsr hearing
[judge] => Patterson
[language] => Spanish
[place] => 24A
)
) etc
and a couple other arrays containing arrays of child records, like so:
// children
Array
(
[73662] => Array
(
[0] => stdClass Object
(
[id] => 11159
[surnames] => Ogando
[given_names] => Diógenes
)
)
[73770] => Array
(
[0] => stdClass Object
(
[id] => 10404
[surnames] => Rodriguez
[given_names] => Jose Hernando
)
)
// etc
)
My idea is to display this by iterating through the parents and checking for
the existence of children
foreach ($parents as $parent) {
// print columns from parent, and...
if (array_key_exists($parent->id, $children) {
// display $children[$parent->id]
}
}
and I am wondering if it's possible to use a partialLoop helper for this,
since it seems that the partialLoop helper needs all its data to be passed
in the single $model argument. My sense is that the partialLoop is not
suited to this type of scenario and I am better off with a simple partial
and looping with foreach.
btw I realize I can loop through the parent objects and pre-stuff them with
data from the corresponding children, and then pass that to the partialLoop,
but that seems to defeat the purpose. I also considered doing this in the
model class itself, but it seems inefficient to loop through the whole thing
twice -- once to load up the data structure and then again in the view to
display it.
Any thoughts?
--
David Mintz
http://davidmintz.org/
It ain't over:
http://www.healthcare-now.org/