boolean $DB_DataObject->getLinks (
string $variableFormat
)
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.
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');
boolean
- TRUE on success and FALSE on failure
This function can not be called statically.
Two Example Tables
Loading all the related objects
<?php
$person = new DataObjects_Person;
$person->get(1079);
$person->getLinks();
print_r($person);
?>
Resulting SQL
Resulting Output
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