我遇到了问题。我想在mysql数据表的多行中插入多重检查值....但是当我插入它时,它存储在一行... 我该怎么办呢...... 我的模型是:
public function apply_for_work_check()
{
$variable = $this->input->post('Infrashtructure');
$data = array(
'id' =>null,
'works_id' => 1,
'infrashtructure_name' => json_encode(implode(",", $variable)),
);
$result=$this->db->insert('infrashtructure_txn_info',$data);
if($result)
{
return TRUE;
}
else
{
return FALSE;
}
}
答案 0 :(得分:1)
更改您的方法如下:
public function apply_for_work_check()
{
$variable = $this->input->post('Infrashtructure');
foreach ($variable as $key => $value) {
$data = array(
'id' => null,
'works_id' => 1,
'infrashtructure_name' => $value,
);
$result = $this->db->insert('infrashtructure_txn_info', $data);
}
if ($result) {
return true;
} else {
return false;
}
}
答案 1 :(得分:1)
{fail_if_no_peer_cert, true}
答案 2 :(得分:0)
$data = explode(",", $variable);
此后。
'infrashtructure_name' => json_encode(implode(",", $data))