【发布时间】:2022-01-23 11:49:14
【问题描述】:
我有 2 张桌子; db_file_acess and db_file_access_details。我在db_file_access_details 表中有一个列subjects_id。从 UI 中,我可以选择几个带有其他详细信息的主题 [array] 并将它们插入到 db_file_acess 表中,并将 subject_ids 插入到 db_file_access_details 中。插入没问题,但是当我更新这两个表时,我似乎无法更新所有行。这是我的更新查询
$result = array();
foreach ($subject_id as $key => $val) {
$result[] = array(
'file_access_id' =>$q_id,
'subjects_id' => $_POST['subject_id'][$key]
);
}
$this->db->update_batch('db_file_access_details', $result, 'file_access_id');
result() 数组如下共享:
Array
(
[0] => Array
(
[file_access_id] => 45
[subjects_id] => 1
)
[1] => Array
(
[file_access_id] => 45
[subjects_id] => 3
)
[2] => Array
(
[file_access_id] => 45
[subjects_id] => 4
)
)
【问题讨论】:
标签: codeigniter