@@ -598,6 +598,84 @@ public function purgeTable($tableName, $isPrivate = true) {
598
598
}
599
599
600
600
}
601
+
602
+ /**
603
+ * This interface inserts or updates relational data
604
+ *
605
+ * For each Row that is passed in:
606
+ * - If a row is found having the same key as the passed in row, update the record.
607
+ * - If no matching row is found, insert a new row setting the column values to those passed in the request.
608
+ *
609
+ * Only one hundred rows may be passed in a single insertUpdateRelationalTable call!
610
+ */
611
+ public function insertUpdateRelationalTable ($ tableId , $ rows ) {
612
+ $ processedRows = array ();
613
+ $ attribs = array ();
614
+ foreach ($ rows as $ row ) {
615
+ $ columns = array ();
616
+ foreach ($ row as $ name => $ value )
617
+ {
618
+ $ columns ['COLUMN ' ][] = $ value ;
619
+ $ attribs [5 ]['COLUMN ' ][] = array ('name ' => $ name );
620
+ }
621
+
622
+ $ processedRows ['ROW ' ][] = $ columns ;
623
+ }
624
+
625
+ $ data ["Envelope " ] = array (
626
+ "Body " => array (
627
+ "InsertUpdateRelationalTable " => array (
628
+ "TABLE_ID " => $ tableId ,
629
+ "ROWS " => $ processedRows ,
630
+ ),
631
+ ),
632
+ );
633
+
634
+ $ response = $ this ->_request ($ data , array (), $ attribs );
635
+ $ result = $ response ["Envelope " ]["Body " ]["RESULT " ];
636
+
637
+ if ($ this ->_isSuccess ($ result )) {
638
+ return true ;
639
+ } else {
640
+ throw new \Exception ("insertUpdateRelationalTable Error: " .$ this ->_getErrorFromResponse ($ response ));
641
+ }
642
+ }
643
+
644
+ /**
645
+ * This interface deletes records from a relational table.
646
+ */
647
+ public function deleteRelationalTableData ($ tableId , $ rows ) {
648
+ $ processedRows = array ();
649
+ $ attribs = array ();
650
+ foreach ($ rows as $ row ) {
651
+ $ columns = array ();
652
+ foreach ($ row as $ name => $ value )
653
+ {
654
+ $ columns ['KEY_COLUMN ' ][] = $ value ;
655
+ $ attribs [5 ]['KEY_COLUMN ' ][] = array ('name ' => $ name );
656
+ }
657
+
658
+ $ processedRows ['ROW ' ][] = $ columns ;
659
+ }
660
+
661
+ $ data ["Envelope " ] = array (
662
+ "Body " => array (
663
+ "DeleteRelationalTableData " => array (
664
+ "TABLE_ID " => $ tableId ,
665
+ "ROWS " => $ processedRows ,
666
+ ),
667
+ ),
668
+ );
669
+
670
+ $ response = $ this ->_request ($ data , array (), $ attribs );
671
+ $ result = $ response ["Envelope " ]["Body " ]["RESULT " ];
672
+
673
+ if ($ this ->_isSuccess ($ result )) {
674
+ return true ;
675
+ } else {
676
+ throw new \Exception ("deleteRelationalTableData Error: " .$ this ->_getErrorFromResponse ($ response ));
677
+ }
678
+ }
601
679
602
680
/**
603
681
* Import a list/database
0 commit comments