2014-10-31 30 views
0

我想比較多維數組,並使用API​​將獨特的數據從mysql添加到雲數據庫。需要幫助比較並添加來自多維數組的唯一數據

如果找不到匹配項,請執行搜索,然後添加它。否則跳到下一個。我嘗試使用下面的代碼,但它不會添加任何數據。

 $records=array(

     'SO Qty' => 'Dup !', 
     'WO Qty'   => $row['Reference'], 
     'SO Date'   => $row['TransactionDate'], 
     'Color'   => $row['DistNumber'], 
     'SO#'   => $row['Reference'], 
     'Promised Date'   => $row['GoodThruDate'], 
     'SalesDescription'   => $row['SalesDescription'], 

    ); 

    $tv->addRecord($tableId, $records); // call to addRecord() which adds data to cloud DB 

表A:從表中的記錄,我想將數據添加到

Array ( 
     [id] => 3054535376 
     [table_id] => 50240233993 
     [created] => 2014-10-30T09:52:15-0600 
     [updated] => 2014-10-30T09:52:15-0600 
     [created_by] => 3045444045538 
     [fields] => Array ( 
         [Work Order] => 87565 
         [SalesDescription] => 18X5X12 1/8 SOLID FORKLIFT TIRE PRESS-ONS 
         [SO#] => 14061 
         [SO Date] => 2013-10-16T00:00:00-0600 
         [Promised Date] => 2014-10-30T09:52:15-0600 
         [SO Qty] => 1.0000000000000000000 
         [WO Qty] => 14061 
         [Color] => 2 
         [s] => 2 
         [SHIP BY] => 2014-10-29 
         [CALC PROMISED DATE] => 2014-10-30 
         ) 
    ) 

表B:從表中的記錄,我想從

Array ( 
     [0] => CAS001 
     [CustomerId] => CAS001 
     [1] => CASH CUSTOMER 
     [Customer_Bill_Name] => CASH CUSTOMER 
     [2] => Will Call 
     [WhichShipVia] => Will Call 
     [3] => [INV_POSOOrderNumber] => [4] => 2013-07-24 
     [ShipByDate] => 2013-07-24 
     [5] => [GoodThruDate] => [6] => [CustomerSONo] => [7] => 13867 
     [Reference] => 13867 [8] => 2013-07-24 
     [TransactionDate] => 2013-07-24 
     [9] => 1 
     [DistNumber] => 1 
     [10] => 2.0000000000000000000 
     [Quantity] => 2.0000000000000000000 
     [11] => 121130581 
     [ItemId] => 121130581 
     [12] => 18X5X12 1/8 SOLID FORKLIFT TIRE PRESS-ONS 
     [SalesDescription] => 18X5X12 1/8 SOLID FORKLIFT TIRE PRESS-ONS 
     [13] => [PartNumber] => [14] => 18X5X12 1/8 SOLID FORKLIFTTIRE 
     [ItemDescription] => 18X5X12 1/8 SOLID FORKLIFTTIRE 
     ) 
+0

問題是什麼? – 2014-11-02 00:05:51

+0

@Leandro謝謝!抱歉的困惑,這裏是我的問題,每當我重新運行或刷新PHP頁面添加新的和現有的記錄。我想避免添加重複記錄 – KGK 2014-11-02 00:08:49

回答

1
獲取數據

$dont_write從未設置爲0?

+0

正確,我該如何處理? – KGK 2014-10-31 19:21:25

+0

'$ dont_write = 0;'? – AlpineCoder 2014-10-31 19:26:11

+0

此外,它可能只是因爲它從這段代碼中缺少,但是'$ row'(您獲取新記錄的數據)在這裏的任何位置都不會被初始化。 – AlpineCoder 2014-10-31 19:30:05