[eluser]Maglok[/eluser]
Yeah I tried that first, but I got cast errors. I tried array_merge next, but that kept making it end up in an array (after messing around with casting to objects for a while).
Then I just tried this:
Code:
// set stuff
$this->stuffz = new Stuff();
$i = 0;
foreach($this->stuffcontainers as $stuffcontainer)
{
$this->stuffz = $stuffcontainer->stuffz;
// check what is added together
foreach($this->stuffz as $stuff)
{
echo $i . ': ' . $stuff->name . '<br>';
}
$i++;
}
Based on data:
- $this is a datamapper object
- $this->stuffcontainers = a has_many of the object Stuffcontainers
- A stuffcontainer object has_many Stuff objects.
- $this->stuffz = empty till I call the above method
I was quite surprised to see this work. If $this->stuffcontainers contains 3 instances of the Stuffcontainer object then I was kind of expecting to just see the stuff value from the last assigned to $this->stuffz. Instead they are all assigned. I am confused as to why.