The related outboundform
row's properties should be accessible in the result object prefixed with the relation's name. So the id
becomes outboundform_id
, the reference_type
becomes outboundform_reference_type
and so on.
The problem is that all_to_array()
doesn't transfer those to the array version of results.
If you want to include them you will have to explicitly list them:
$arrAll = $p->/* snip */->all_to_array(array('id', 'name', 'outboundform_id', 'outboundform_reference_type')); // Project fields and outboundform fields too
If you have an instance of any model, you can get the list of fields by the $instance->fields
property of that model (from the database table), and use those to create the list for the all_to_array
call by creating prefixed names for the included relation.
Alternatively, if you only need the []
way of accessing fields, you can implement ArrayAccess
interface like this:
class DataMapper2 extends DataMapper implements ArrayAccess
{
public function offsetSet($offset, $value)
{
if (is_null($offset)) {
throw new ErrorException('model instances doesn\'t support pushing new fields');
} else {
$this->{$offset} = $value;
}
}
public function offsetExists($offset)
{
return isset($this->{$offset});
}
public function offsetUnset($offset)
{
unset($this->{$offset});
}
public function offsetGet($offset)
{
return isset($this->{$offset}) ? $this->{$offset} : null;
}
}