を値を渡すことはできませんコントローラここは、ここでは、コントローラ機能CodeIgniterのに
public function create($postdate)
{
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->helper('url');
// $postdate = $this->uri->segment(3);
echo $postdate;
$data['title'] = 'Hey there!';
$this->form_validation->set_rules('title', 'Title', 'required');
$this->form_validation->set_rules('text', 'Text', 'required');
if ($this->form_validation->run() === FALSE)
{
$this->load->view('templates/header', $data);
$this->load->view('pages/create',);
$this->load->view('templates/footer');
}
else
{
$this->news_model->set_news($postdate = 20160824);
$this->load->view('pages/success');
}
}
の私のコードであるモデルの私のコードです:
public function set_news($postdate)
{
$this->load->helper('url');
$slug = url_title($this->input->post('title'), 'dash', TRUE);
$data = array(
'title' => $this->input->post('title'),
'slug' => $slug,
'text' => $this->input->post('text'),
'room_date' => $postdate
);
return $this->db->insert('news', $data);
}
が、モデルが値$ POSTDATEを挿入されていませんデフォルトの値20160824を挿入しています。コントローラのエコーがパラメータとして渡された値を示している、つまり私はデータベースに挿入したい(正しい)値です。
column_dateのデータ型は? –
私はcodeignitorの初心者ですので、私は自分自身にcreate()フォームを送信していました。その問題を引き起こしました。解決済み! 1048 列 'room_date' 'news'(' title'、 'slug'、' text'、 'room_date')ちょうど楽しみのためのVALUES( 'INTO INSERT nullにすることはできません。 –