插入查询无法正常工作无法在Codeigniter中使用isset()

时间:2018-12-03 08:58:24

标签: php codeigniter

代码:

$data = array(
    'fname' => isset($this->input->post('fname')) ? $this->input->post('fname'):"",
    'lname' => isset($this->input->post('lname')) ? $this->input->post('lname'):"",
    'gender' => isset($this->input->post('gender')) ? $this->input->post('gender'):"",
    'dob' => isset($this->input->post('dob')) ? $this->input->post('dob'):"",
    'marital_status' => isset($this->input->post('marital_status')) ? $this->input->post('marital_status'):"",
);
$sql = $this->db->insert('personal_detail',$data);

在此代码中,我具有表personal_detail,并且已将fname,lname,gender,dob,marital_status定义为列名,并且在单击“提交”按钮(即

)时出现了点错误。
Cannot use isset() on the result of an expression (you can use "null !== expression" instead)

,如果我删除了isset(),它将显示Column 'fname' not to be null。因此,我该如何解决该问题。请帮助我。

谢谢

0 个答案:

没有答案