Hello
Following the instructions at
http://rtfm.modx.com/display/xPDO20/getOne
I have this behaviour and I’m curious to understand why it goes this way...
When I do
$projects = $modx->getCollection('cpoProject',$c);
$list = array();
foreach ($projects as $project) {
$owner = $project->getOne('Company'); // Company is the alias for aggregate relashionship in object 'cpoProject'
$projectArray = $project->toArray();
$projectArray['owner'] = $owner->get('name');
$list[]= $projectArray;
}
return $this->outputArray($list,$count);
The line "$projectArray[’owner’] = $owner->get(’name’);" is the one I’m asking about...
It seems I can do both "$projectArray[’owner’] = $owner->get(’name’);" or "$projectArray[’owner’] = $owner->name;"; with the same result... I suppose the good one is "$owner->get(’name’)" but is the other correct too, why or why not?
Thanks