->getLinks()

->getLinks() – load related objects

Synopsis

boolean $DB_DataObject->getLinks (
string $variableFormat
)

Description

Loads the all the related objects into the main object, by using the links.ini
relationships, and sets the calling objects variables with the row name prefixed
with an underscode (_
) to the resulting objects.

Using this with the earlier column naming convention is depreciated, and links.ini
files should be used.

Parameter

string $variableFormat
- the default behavior is to assign the resulting
objects to variables with the row name prefixed with an underscode (_
), however,
you can use this value to format the variable differently

examples of formaters

if room.occupied_by is linked to a person.id
without a modifier - eg _%s
results in the equivilant of
$object->_occupied_by = $object->getLink('occupied_by');
with a modifier - eg link_%s
results in the equivilant of
$object->link_occupied_by = $object->getLink('occupied_by');

is caused by the original link code using {tablename}_{colname} for guessing links, this automatedlinking should be ignored, and not used, as it is depreciated.

Example with three tables join

<?php/** * The following example show a three tables join. * * More joins can be nested as you see fit. */$person = new DataObjects_Person;

$data = array();if ($person->find()) { while ($person->fetch()) {$person->getLinks();// Following is another call to getLinks for the second join$person->_convention_id->getLinks();$data[] = $person->_convention_id->_room_id->ToArray(); }}

print_r($data);?>

databasename.links.ini

; this ini file is for the three tables join example above.[person]person_id = convention:person_id