I can't seem to nail the exact rule of thumb as to what is added to an array when using toArray()
, insomuch that if I was to do something like this:
$sheep = SheepQuery::create()->find();
foreach ($sheep as $sheepii) {
$sheepii->getShepherd();
}
return $sheep->toArray();
or some variation of it, sometimes I seem to get results with both the columns from the sheep table and their sub-arrays with the shepherd, but sometimes it doesn't seem to include it, so I have to do something like add the values to a new array as I loop over.
Can anyone point out (a link explaining) why this happens and the rules behind it so I'm not blindly guessing, and if there's a nicer way of doing the same thing above by all means I'm open to suggestion.