您好,请帮我,当我向2个表中添加大量数据时出现问题。 遵循我编写的代码
$this->db->trans_start();
$result = [];
foreach($data1 as $key => $val){
$response["pesan"]="";
$result[] = [
"data1" => $data1[$key],
"data2" => $data2[$key],
"data3" => $data3[$key]
];
}
$this->db->insert_batch('table1', $result);
$last_id = $this->db->insert_id();
$result1 = [
"data1" => $data1,
'data2' => $data2
];
$this->db->insert('table2',$result1);
$this->db->trans_complete();
echo json_encode($response);
答案 0 :(得分:0)
我认为您应该遵循mvc模式。