[eluser]OverZealous[/eluser]
OK, for starters, does Document have one or many Users? One or many Document Types? I would guess you only have one.
If you only have one, you don't need the ->all. You just do this (for example):
Code:
$type = $obj->typesdocuments->get();
As for your question, the original DataMapper doesn't provide a way to join these results. You will have to pass in all Documents to your view, then loop through each document, get() the user and type, and process them:
Code:
<? foreach($documents as $doc):
$doc->profiles->get(); // adds a query for each $doc
$doc->typesdocuments->get(); // adds another query for each $doc
?> output data here <?= htmlspecialchars($doc->profiles->name) ?>
<? endforeach; ?>
If you were to try DMZ, you could actually include columns from $has_one related items and reduce your number of queries substantially. It would look like this in the controller:
Code:
$documents->include_related('profile', array('name')); // include just the name column
$documents->include_related('typesdocument', '*'); // include all of the type columns
$documents->get();
And this is your view:
Code:
<? foreach($documents as $doc): ?>
<tr>
<td><?= htmlspecialchars($doc->id) ?></td>
<td><?= htmlspecialchars($doc->profile_name) ?></td>
<td><?= htmlspecialchars($doc->typesdocument_name) ?></td>
</tr>
<? endforeach; ?>
I don't have everything labeled the same, so I apologize if that trips you up.
Also, a suggestion:
1) Make sure you name your variables correctly. It's confusing (for me at least) to have a variable called $objetos, because there is no
meaning to your variable. If you had called it $documents (or whatever is correct in your language) – and passed it in as 'documents' – it would be easier for you to read and any developers down the road.