木下 敏夫
kino****@tktoo*****
2008年 7月 11日 (金) 12:18:27 JST
木下です。
私も kunitsujiさんもそちらと同じ環境にあるわけではないので
机上の空論で多分こうだろうという流れを示しているに過ぎません。
内容を吟味して足りないところ等は適時追加していってくださいね。
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 が指定されていなかった。
}
}
なんか流れがおかしいな?
--
木下敏夫
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
-------------------------------------------------------------------------