我遇到了一个问题。我想在 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;
}
}
最佳答案
public function apply_for_work_check()
{
$result=array();
$variable = $this->input->post('Infrashtructure');
foreach($variable as $var){
$data = array('id' =>null,'works_id' => 1,
'infrashtructure_name' => json_encode($var));
$result[]=$this->db->insert('infrashtructure_txn_info',$data);
}
if(count($result)==array_sum($result)) {#checks if all was TRUE
return TRUE;
} else {
return FALSE;
}
}
关于php - 使用codeigniter在mysql的多行中插入多个检查值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42646430/