Forgot password? | Forgot username? | Register

Reverse Attachments in Web 5 Objects

Reverse Attachments in Web 5 Objects

Perhaps this has already been addressed and I missed it. I hope so.

The inability of the "Web 5 Objects" to easily include reverse attachments is, I believe, a fairly serious handicap to what is otherwise a very useful set of class objects.

Is there any plan to add this functionality? It would be very useful and would save those of us who are developing sites with the Web 5 Objects a lot of trouble.

Thanks,
Richard

Edited by: - 01-Jan-70 09:00:00

Administrator has disabled public posting. Please login or register in order to proceed.

Re: Reverse Attachments in Web 5 Objects

Hi Richard,

Before we started writing the "web 5" objects we decided that one of the main objectives of the development would be to keep them as simple as possible while presenting a simpler interface to EMu than pure TexQL. We think that on the whole we have achieved this; but an obvious difference between the current web 5 objects and the original PHP interface is the omission of logic to assist with reverse attachments.

The logic behind a reverse attachment is simple: run another query on a different module, finding records that link to this record through an attachment field. Effectively you seed the reverse attachment query with the IRN of the current record.

As such, programmatically adding reverse attachment logic to the web 5 objects is trivial; all the functionality required to return reverse attachments is already present in the Query class, so all we would need to do is add a function that itself would use a Query class instance to run the required additional queries.

The problem is the syntax you would use to specify reverse attachments. In the current web 5 model, you return data from attachment fields by using the familiar syntax as a string:
"CreCreatorRef_tab->eparties->SummaryData" (for example)
This then results in the returned results object being a native PHP object like this:
$results[$i]->CreCreatorRef_tab[$j]->SummaryData
This obviously has a number of benefits over the previous PHP library and allows you to very easily loop through and test properties of results, fields and links.

Where this nice syntax breaks down is with Reverse Attachments. Try as we might we have not yet found a really clean way of implementing the syntax for these. You might think that the "reverse arrow" (<-) would be a nice syntax to use, and on the face of it it would, but in practice it leads to fairly messy code. How would you specify a reverse attachment to the current catalogue record from the loans module, through the link ObjObjectsLoanedRef_tab? One example you could use looks a bit messy to me:
"irn<-ObjObjectsLoanedRef_tab<-eloans<-SummaryData"
Furthermore, if this format were acceptable, how would we format the returned $results object when the "<-" symbol isn't a native PHP operator?

It is at this point in the discussion that I personally think the benefits of implementing reverse attachment logic in the web 5 objects begin to be outweighed by the disadvantages the more complex application code would bring. This is why the logic is not present in the current web 5 objects - simply because we haven't yet agreed on a nice way to implement the syntax. The philosophy behind the web 5 design has always been "clean and simple", and building your own reverse attachment logic using the current web 5 objects, to me, seems simpler and cleaner than bending the PHP language and syntax to fit our needs.

This is of course an ongoing discussion and I'd be very interested to know your thoughts as another end user of the web 5 code. How would you like to see the syntax implemented?

All the best,

Alex

Alex Fell (Axiell Manchester)
useravatar
Offline
8 Posts
Administrator has disabled public posting. Please login or register in order to proceed.
There are 0 guests and 0 other users also viewing this topic