boolean $DB_DataObject->getLinks (
string $variableFormat
)
links.iniの関連情報を使用して、
メインオブジェクトに関連する全てのオブジェクトをロードします。
また、アンダースコア (_
) 付きの行名で
呼び出しているオブジェクト変数を結果オブジェクトにセットします。
以前のカラム名変換を使用することは推奨されません。 links.ini ファイルが使用されます。
string $variableFormat
-
デフォルトの振る舞いは、行名の前にアンダースコア
(_
)
を付けた変数を結果のオブジェクトに割り当てることです。
しかしながら、この値を様々な異なるフォーマットにすることができます。
フォーマッタの例
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、失敗時は FALSE
This function can not be called statically.
2つの例の表
全ての関連するオブジェクトをロードする
<?php
$person = new DataObjects_Person;
$person->get(1079);
$person->getLinks();
print_r($person);
?>
結果の SQL
結果の出力
3つの表の結合例
<?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