牧尾竜一
ryuic****@jom*****
2008年 7月 11日 (金) 11:47:05 JST
JOMRです
木下さん。はじめまして宜しくお願いします。
木下さん、kunitsujiさんの指摘どおりまとめてみました。
function edit($cu_id = '')
{
$edit = (int) $this->input->post('edit');
if ($edit == 1)
{
$data = array(
'cu_name' => $this->input->post('cu_name'),
'cu_kana' => $this->input->post('cu_kana'),
'cu_tel' => $this->input->post('cu_tel'),
'cu_fax' => $this->input->post('cu_fax'),
'cu_mail' => $this->input->post('cu_mail'),
'biko' => $this->input->post('biko'),
'datetime'=> date('Y-m-d H:i:s', time()),
);
$cu_id = (int) $cu_id;
$this->db->update('customer', $data, array('cu_id' => $cu_id));
$this->load->view('customer_edit_finished');
}
else
{
$cu_id = (int) $cu_id;
$this->db->where('cu_id', $cu_id);
$query = $this->db->get('customer');
if ($query)
{
$row = $query->row();
$data = array(
'cu_name' => $row->cu_name,
'cu_kana' => $row->cu_kana,
'cu_tel' => $row->cu_tel,
'cu_fax' => $row->cu_fax,
'cu_mail' => $row->cu_mail,
'biko' => $row->biko,
);
}
else
{
//cu_idでデータが取り出せなかった
}
}
}
これでためしたらエラーはなくなったのですが編集内容が反映されませんでした。
なんとなくですが、$this->load->view('customer_edit_confirm', $data);
> の$dataがひつようなきがしますね^^指摘されていますが。
>
> 意図した結果を出すにはこうかな?
>
> IF文の判定のelseいこうですね。
>
> else
> {
> $cu_id = (int) $cu_id;
> $this->db->where('cu_id', $cu_id);
> $query = $this->db->get('customer');
> if ($query)
> {
> $row = $query->row();
> $data = array(
> 'cu_name' => $row->cu_name,
> 'cu_kana' => $row->cu_kana',
> 'cu_tel' => $row->cu_tel',
> 'cu_fax' => $row->cu_fax',
> 'cu_mail' => $row->cu_mail',
> 'biko' => $row->biko',
> }
> else
> {
> //cu_idでデータが取り出せなかった
> }
> }
>
>
>> kunitsujiさんのも取り入れると
>>
>>
>> function edit($cu_id = '')
>> {
>> $edit = (int) $this->input->post('edit');
>> if ($edit == 1)
>> {
>> $data = array(
>> 'cu_name' => $this->input->post('cu_name'),
>> 'cu_kana' => $this->input->post('cu_kana'),
>> 'cu_tel' => $this->input->post('cu_tel'),
>> 'cu_fax' => $this->input->post('cu_fax'),
>> 'cu_mail' => $this->input->post('cu_mail'),
>> 'biko' => $this->input->post('biko'),
>> 'datetime'=> date('Y-m-d H:i:s', time()),
>> );
>>
>> $cu_id = (int) $cu_id;
>> $this->db->where('cu_id', $cu_id);
>> $this->db->update('customer', $data, $cu_id);
>> $this->load->view('customer_edit_finished');
>> }
>> else
>> {
>> $this->load->view('customer_edit_confirm', $data);
>> }
>> }
>>
>> --
>> 木下敏夫
>> mailto:kino****@tktoo*****
>> http://www.tktools.jp/
>> http://okusama-shop.com/
>> http://www.oidc.jp/bmb/index.php?topic=-m-D14
>> -------------------------------------------------------------------------
>> ビジネスマッチングブログ・キックオフセミナーにパネリストとして参加します。
>> http://www.oidc.jp/bmb/article.php/20080207143305526
>> -------------------------------------------------------------------------
>>
>> _______________________________________________
>> Codeigniter-users mailing list
>> Codei****@lists*****
>> http://lists.sourceforge.jp/mailman/listinfo/codeigniter-users
>
> _______________________________________________
> Codeigniter-users mailing list
> Codei****@lists*****
> http://lists.sourceforge.jp/mailman/listinfo/codeigniter-users
>
>
> No virus found in this incoming message.
> Checked by AVG - http://www.grisoft.jp
> Version: 8.0.138 / Virus Database: 270.4.7/1545 - Release Date: 2008/07/10 18:43
>
>
>