Ticket #23 (closed enhancement: fixed)
Add possibility to define own method names for using foreign key relationships
| Reported by: | maulin@… | Owned by: | hans |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.3 |
| Component: | Generator | Version: | devel |
| Severity: | trivial | Keywords: | |
| Cc: |
Description (last modified by hans) (diff)
naming of foreignkey relations (ie one:many or many:one relationships) is a little kludgy. It works fine for the usual case, where you are relating to a foreign table that maps to exactly one object. but in many cases, this is not the case. i added a "phpname" attribute to the foreign key in the schema.xml, and then created some wrapper functions in Object.tpl that make them prettier.
example:
old:
<table name="foo"...> <column name="positionId" ...> <column name="groupId" ...> <foreign-key table="code"> <reference local="positionId" foreign="id"/> </foreign-key> <foreign-key table="code"> <reference local="groupId" foreign="id"/> </foreign-key> </table>
setCodeRelatedByPositionId () setCodeRelatedByGroupId ()
with the addition of phpname to foreignkey...
<foreign-key table="code" phpname="position"> <reference local="positionId" foreign="id"/> </foreign-key> <foreign-key table="code" phpname="group"> <reference local="groupId" foreign="id"/> </foreign-key>
now generates:
setPosition() setGroup()
which call the above (ugly named) functions.
pretty easy to add, and makes the api cleaner.
