Page 1 of 1

Adding Multiple Relationship Records w/one form

PostPosted: Sun Oct 09, 2011 1:49 pm
by jb606
First, Xataface is saving me so much time putting my network documentation site together! I'm just missing one part.

Currently, I have three tables NetworkDevices, Ports, and Connections. I have the relationships setup to "connect" DevA(PortX) to DevB(PortX) in the connections table but I need a way to reverse that so when DevA(Port 1) is connected to DevB (Port2) another record is added that the same time connecting DevB(Port2) to DevA(Port1). This there a built-in function to synchronously add records like that? If not I could use the " after_action_existing_related_record" trigger but I don't know how to pull all of the relationship information out though the API yet (I'm still learning). Any tips to point me in the right direction would be very helpfull

Thanks,

Re: Adding Multiple Relationship Records w/one form

PostPosted: Mon Oct 10, 2011 7:49 am
by Jean
Hello,
I did not understand well your problem but I think you can use an AfterSave trigger like that for example :
Code: Select all
function afterSave(&$record){
$this->app =& Dataface_Application::getInstance();
$otherrcontent=$record->val('field');
$result= mysql_query("UPDATE table set field='$content' where field='$otherrcontent'", $this->app->db());
}

You can build any query you want in any table.
Cheers
Jean

Re: Adding Multiple Relationship Records w/one form

PostPosted: Wed Oct 12, 2011 3:38 pm
by jb606
Basically trying to create a "mirror" record. I need to figure out how to pull out the Src* columns from the relationship and the Dst columns from the user and flip them.

|SrcDevID | SrvDevPortID | DstDevID | DstDevPortID|
| Dev1 | port 1 | Dev2 | port 20 | <----------That's the easy part but...
| Dev2 | port 20 | Dev1 | port 1 | <----------I'd like to have the reverse created at the same time

--relationships.ini---
[DeviceConnections]
action:label = "Connect To Device"
DeviceConnections.SrcDevPortID = "$DevicePortID"
DeviceConnections.SrcDevID = "$DeviceID"