我已经在PHP My Admin中从我的MySQL数据库导出了数据。我将它导出为PHP数组。
$measurements = array(
array('measurement_id' => '1','measurement_name' => 'bag','measurement_last_updated' => '2018-01-03 14:40:49'),
array('measurement_id' => '2','measurement_name' => 'bowl','measurement_last_updated' => '2018-01-03 14:40:49'),
array('measurement_id' => '3','measurement_name' => 'box','measurement_last_updated' => '2018-01-03 14:40:49'),
array('measurement_id' => '4','measurement_name' => 'handful','measurement_last_updated' => '2018-01-03 14:40:49'),
array('measurement_id' => '5','measurement_name' => 'package','measurement_last_updated' => '2018-01-03 14:40:49'),
array('measurement_id' => '6','measurement_name' => 'piece','measurement_last_updated' => '2018-01-03 14:40:49'),
array('measurement_id' => '7','measurement_name' => 'pizza','measurement_last_updated' => '2018-01-03 14:40:49'),
array('measurement_id' => '8','measurement_name' => 'slice','measurement_last_updated' => '2018-01-03 14:40:49'),
array('measurement_id' => '9','measurement_name' => 'spoon','measurement_last_updated' => '2018-01-03 14:40:49'),
array('measurement_id' => '10','measurement_name' => 'teaspoon','measurement_last_updated' => '2018-01-03 14:40:49'),
array('measurement_id' => '11','measurement_name' => 'tablespoon','measurement_last_updated' => '2018-01-03 14:40:49')
);
如何将其再次插入数据库?
这就是我的尝试:
$array_size = sizeof($measurements);
for($x=0;$x<$array_size;$x++){
$temp = $measurements[$x];
print_r($temp);
}
答案 0 :(得分:0)
如果您开始使用该结构,我会做类似的事情:
NaN === NaN
然后在另一个函数中:
foreach($measurements as $v){
functionForInsertingRows($v)
}
请注意:这是伪代码,但这是我会使用的想法。插入或更新函数将使用您喜欢的任何技术来更改数据库。