牧尾竜一
ryuic****@jom*****
2008年 7月 11日 (金) 08:52:31 JST
JOMRです。
前回に引き続きデータ編集できるメソッドを作成しました。
ただこれだと、editにいくと「 レコードを更新するには、"set" メソッドを使
う必要があります。 」といったエラーになってしまいます。
以下が作成したものです。
function edit_confirm($cu_id = '')
{
$cu_id = (int) $cu_id;
$edit_confirm = (int) $this->input->post('edit_confirm');
$this->db->where('cu_id', $cu_id);
$query = $this->db->get('customer');
$row = $query->row();
$data['cu_id'] = $row->cu_id;
$data['cu_name'] = $row->cu_name;
$data['cu_kana'] = $row->cu_kana;
$data['cu_tel'] = $row->cu_tel;
$data['cu_fax'] = $row->cu_fax;
$data['cu_mail'] = $row->cu_mail;
$data['biko'] = $row->biko;
$data['datetime'] = $row->datetime;
$this->db->set('cu_id', $cu_id);
$this->load->view('customer_edit_confirm', $data);
}
function edit($cu_id = '')
{
$cu_id = (int) $cu_id;
$edit = (int) $this->input->post('edit');
$this->db->where('cu_id', $cu_id);
if ($edit == 1)
{
$this->db->where('cu_id', $cu_id);
$query = $this->db->get('customer');
$row = $query->row();
$cu_id = $row->cu_id;
$cu_name = $row->cu_name;
$cu_kana = $row->cu_kana;
$cu_tel = $row->cu_tel;
$cu_fax = $row->cu_fax;
$cu_mai = $row->cu_mail;
$biko = $row->biko;
$datetime = $row->datetime;
$data['cu_id'] = $row->cu_id;
$data['cu_name'] = $row->cu_name;
$data['cu_kana'] = $row->cu_kana;
$data['cu_tel'] = $row->cu_tel;
$data['cu_fax'] = $row->cu_fax;
$data['cu_mail'] = $row->cu_mail;
$data['biko'] = $row->biko;
$data['datetime'] = $row->datetime;
$this->db->update('customer');
$this->load->view('customer_edit_finished');
}
else
{
$this->load->view('customer_edit_confirm', $data);
}
}
出来ればこれをmodelにしていきたいのですがなかなかうまくいかないです。
少しずつ改良して納得のいくものにしたいです。
できれば助言宜しくお願いします。