Hi there,
Background:
I have a table called courses and a table called students, and a third join table. I am track course payments by the students in this join table.
In the join table are the requisite two primary keys from the source tables, as well as these fields:
- cost
- amount paid
- amount owing
What I want:
amount owing = cost - amount paying
Two approaches attempted:
1) Added a delegate class trigger for the join table to populate the amount owing field.
Problem #1: Produces an output error, I suspect because delegate classes aren't intended for join tables.
Problem #2: The record object is populated with the "cost" and "amount paid" fields, which is good, but not with StudentID field, so I do not know what to specify in the where clause when updating the record with Mysql.
Both problems would need to be solved.
2) Tried specifying a custom __sql__ query in fields.ini for the join table to do a true mysql calculated field (whereby the field does not exist in the database but is constructed dynamically based on other fields).
Problem: custom __sql__ queries are not allowed in fields.ini.
Does anyone have any suggestions on either approach, or perhaps another?
Many thanks,
Shiraz