我已经在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);
}
1条答案
按热度按时间gwo2fgha1#
如果你开始使用这种结构,我会做如下事情:
然后在另一个函数中:
注意:这是psuedo代码,但这是我将使用的想法。insert或update函数将使用任何您想要的技术来更改数据库。