我试图列出然后从这个数组插入到 SQL 表中:
SQL表:
id time average_position search_visibility_index click_potential
数据是:
Array
(
[name] => average_position
[series] => Array
(
[0] => Array
(
[0] => 2020-03-18
[1] => 36.27
)
[1] => Array
(
[0] => 2020-03-19
[1] => 36.23
)
[2] => Array
(
[0] => 2020-03-20
[1] => 36.18
)
[3] => Array
(
[0] => 2020-03-21
[1] => 36.07
)
[4] => Array
(
[0] => 2020-03-22
[1] => 36.53
)
[5] => Array
(
[0] => 2020-03-23
[1] => 36.65
)
[6] => Array
(
[0] => 2020-03-24
[1] => 36.21
)
问题是如何使用单个 mysql 查询保存这些数据,因为有多个数组。但所有这些都是基于固定日期时间查询。
foreach($contents_series as $avg_array){
DB::table('data_series')->insert(
['time' =>$avg_array[0],'average_position' =>$avg_array[0]['url_series'][0]['series'][1]]
);
MMMHUHU