Jump to content

AtkManyToOneRelation: Difference between revisions

From NusaATK
setLocalKey/setRemoteKey
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{relation}}
== atkManyToOneRelation ==
== atkManyToOneRelation ==
function atkManyToOneRelation($name, $destination, $flags=0)
* $name The name of the attribute.
* $destination The node we have a relationship with.


If you do not want to use the default primary keys (for example when the * side has a combined PK), you can override them by using the functions:
If you do not want to use the default primary keys (for example when the * side has a combined PK), you can override them by using the functions:
<syntaxhighlight lang="php">
  setLocalKey("a_id");
  setLocalKey("a_id");
  setRemoteKey("b_id");
  setRemoteKey("b_id");
</syntaxhighlight>


'''Example'''
'''Example'''
Line 14: Line 14:


[[image:atkManyToOne.jpg|center]]
[[image:atkManyToOne.jpg|center]]
When you use the AF_LARGE flag it is possible to customise the text for the select link, [[See Renaming_'add'_and_'select'_links_in_relations]].
=== Example atkMetaNode ===
An Employee has one department
  public static function meta(atkMetaPolicy $policy) {
      $policy->hasOne('department');
  }


[[Category:Relations]]
[[Category:Relations]]

Latest revision as of 09:30, 4 October 2010

atkManyToOneRelation screenshot

atkManyToOneRelation

If you do not want to use the default primary keys (for example when the * side has a combined PK), you can override them by using the functions:

 setLocalKey("a_id");
 setRemoteKey("b_id");

Example

Projects all have one coordinator (node B), but one coordinator can have multiple projects (node A). So in the project class, there's a atkManyToOneRelation to a coordinator.

When you use the AF_LARGE flag it is possible to customise the text for the select link, See Renaming_'add'_and_'select'_links_in_relations.

Example atkMetaNode

An Employee has one department

 public static function meta(atkMetaPolicy $policy) {
     $policy->hasOne('department');
 }