这是我的php数组
$j_obj = Array
(
[Cluster] => 1
[Cost] => 48
[Conversions] => 20
[MyColumn] => 45
)
Array
(
[Cluster] => 1
[Cost] => 46
[Conversions] => 20
[MyColumn] => 37
)
Array
(
[Cluster] => 1
[Cost] => 47
[Conversions] => 19
[MyColumn] => 40
)
上面的json数组不是静态的,它是动态的。
我需要在mysql insert query中插入数组值。我尝试以下
foreach ($j_obj as $row)
{
print_r(implode(',', $row));
//$sql = "insert into $tbl_name values(implode(',', $row))";
//我从打印$ row
获得了这个值 //1,48,20,451,46,20,371,47,19,401,51,6
我需要的是什么
//$sql = "insert into $tbl_name values(1,48,20,451),(46,20,371,47),(19,401,51,6)";
}
表和列也是从json值
动态创建的有人能帮助我吗?