Saving related records

A place for users and developers of the Xataface to discuss and receive support.

Saving related records

Postby jay » Fri Mar 25, 2011 7:06 am

Hi.

Is there a way to store the related records of a relationship at once? E.g.: if I have a University class and a university can have many faculties, is it possible to do something like this?:
$uni = new Dataface_Record('universities', array(...));
$uni->save();
$uni->save_related('faculties', array-of-faculties);

It would be nice to have a function that deletes the faculties that are no longer in the relationship, update the ones that changed and insert the new ones.
The framework is pretty nice, but maybe that's asking too much... :)


J.
jay
 
Posts: 13
Joined: Wed Apr 01, 2009 3:39 am

Re: Saving related records

Postby shannah » Fri Mar 25, 2011 10:44 am

There is no function like this right now although there are places in the Xataface framework where similar things are done. E.g. Dataface/IO.php handles the saving of records and it handles special cases for transient fields containing related records (e.g. for the grid widget and checkbox group widgets) -- the implementation of this currently is a bit of a hack (it actually checks for specific widget types... and this shouldn't be necessary in a perfect world).

The Dataface_IO class includes methods that could be used as parts of such a function:
addRelatedRecord
removeRelatedRecord
addExistingRelatedRecord

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 22 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved