我試圖從第n個(這種情況下,第三個內部)數組中的數組插入以下數據到數據庫中。 $bigDataArray
包含另外兩個數組,但我們感興趣的是其中的最後一個(第三個)數組。該$requiredArray
返回這麼多的記錄,並有很多領域。我希望只選擇幾個字段並將與它們關聯的所有值插入到數據庫中。還應該注意的是,由於我們剛剛以這種形式提供了數據,因此從012數據庫中獲取這些數據的操作不是而是。任何援助將不勝感激。Foreach在第n個數組的數據庫中插入多個值
foreach ($bigDataArray->getAll() as $requiredArray) {
foreach ($requiredArray as $cols => $records) {
// just pick the required data for analysis
if($cols == "xx1" || $cols == "xx2" || $cols == "xx4" || $cols == "xxn"){
// I want insert $cols as fields and $row as records in database,then just update values in xx2 if xx1 already exists
}
}
}
的print_r($requiredArray)
`Y \交流\ r \響應對象 ( [無法識別的:保護] =>數組 ( )
[_type:y\ac\r\Response:private] => !re
[attributes:protected] => Array
(
[.id] => 3
[name] => Kelvin
[target] => b.b.bb.g
[parent] => none
[rpap] =>
[rpip] => 8/8
[defval] => default-small/default-small
[l-at] => 512000/1000000
[m-it] => 512000/2000000
[b-l] => 0/0
[b-ld] => 0/0
[b-ti] => 0s/0s
[ck-s] => 0.1/0.1
[activity] => 1645827604/17691224739
[tbs] => 0
[pts] => 11900213/13011698
[tkets] => 0
[loss] => 98154/2662855
[t-loss] => 0
[avg-r] => 70064/2025768
[p-rate] => 155/172
[tpt-rate] => 0
[qets] => 0/4
[tets] => 0
[qutes] => 0/5968
[ttes] => 0
[inv] => false
[dyn] => true
[dis] => false
)
[_tag:_type:y\ac\r\Message:private] =>
)`
你能否給我們提供'$ bigDataArray'的'print_r'? – MinistryofChaps
@MinistryofChaps我們無法訪問'$ bigDataArray'中的所有數據,但僅當我們訪問所提供的方法時才能訪問。我應該爲'$ requiredArray'提供部分嗎? – BekiTheMe
@BikiTheMe你可以不用'print_r($ bigDataArray-> getAll())'來顯示它嗎?如果不是,$ requiredArray會很好。另外,如果你想獲得最後一個$ bigDataArray數組,你可以這樣做:'$ lastArray = $ bigDataArray [count($ bigDataArray) - 1]' – MinistryofChaps