牧尾竜一
ryuic****@jom*****
2008年 7月 11日 (金) 12:33:15 JST
JOMRです。
> 木下です。
>
> 私も kunitsujiさんもそちらと同じ環境にあるわけではないので
> 机上の空論で多分こうだろうという流れを示しているに過ぎません。
>
> 内容を吟味して足りないところ等は適時追加していってくださいね。
了解しました。MLでの説明がなれていないというのはいい訳になってしまいます
が説明が足りないことに関してはこちらの不足要素でした、
自分なりに木下さんがかかれたものに対して説明を足してみましたのでみてもら
えますか?
> function edit($cu_id = '')
> {
> // $cu_id が数値のみになるように(数値以外の場合の処理が必要か?)
//数値以外は必要ではないです。
> $cu_id = (int) $cu_id;
>
> if($cu_id>0)
> {
> // Where句の指定(対象)
> $this->db->where('cu_id', $cu_id);
>
> // 入力内容の edit を比較して処理を分岐
> $edit = (int) $this->input->post('edit');
> if ($edit == 1)
> {
> // 入力内容から $data を作成
> $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()),
//ここは本来更新フィールドを持たせて登録日時と別に登録されたいと考え
ています。
> );
>
> // 既存のデータの確認
> $query = $this->db->get('customer');
> if ($query)
> {
> // 既存のレコードがある場合は更新
> $this->db->update('customer', $data);
> } else {
> // 既存のレコードがある場合は追加
> $this->db->insert('customer', $data);
> }
> // 編集終了の表示
> $this->load->view('customer_edit_finished');
> }
> else
> {
> // 既存のデータの取得
> $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,
> );
> // 編集確認画面を表示 ??
// ここで編集した内容を表示させてから一覧に戻りたいと考えています。
> $this->load->view('customer_edit_confirm', $data);
> } else {
> //cu_idでデータが取り出せなかった
> }
> }
> } else {
> // cu_id が指定されていなかった。
> }
> }
ところどころの追記で見づらくなってしまいましたが宜しくお願いします。