Codeigniter从post方法向数据库中插入日期


codeigniter insert date into database which is sent fom post method

在我的日期输入字段中,我使用日期选择器获取日期。现在我需要知道如何在数据库表中保存特定的日期,我不知道如何在模型中访问日期。

这是表单字段

Date: <input type="text" id="datepicker"/>

这是模型

function save_cheque(){
    $insert_cheque_data = array(
        'name' => $this->input->post('name'),
        'amount' => $this->input->post('amount'),
        'amount_letters' => $this->input->post('amount_in_words'),
        'address' => $this->input->post('address'),
        'account_no' => $this->input->post('acc_no'),
        'bank' => $this->input->post('bank'),
        'date' => $this->input->post('date'),
             ); 
        $this->db->insert('cheque_details',$insert_cheque_data);
        $this->load->database();
        $query = $this->db->query("SELECT MAX(id) AS id FROM companydetails");
        return $query->result();        
}

您只需要给该表单字段一个name,就像任何其他表单字段一样。日期选择器将为您填充一个值。

<input type="text" name="date" id="datepicker"/>

你通常在PHP中访问它:

'date' => $this->input->post('date'),