只是爲了澄清所有答案在這裏工作完美無瑕!自他首次發佈以來,我選擇了Edwins。將數組傳遞給模型?
$this -> load -> model('staff_model');
$this -> load -> library('encrypt');
$arrData = array(
'anum' => $this -> encrypt -> encode($this->input->post('anum')),
'first' => $this -> input -> post('fname'),
'last' => $this -> input -> post('lname'),
'why' => $this -> input -> post('why'),
'aidyear' => $this -> input -> post('aidyear'),
'signintime' => NULL,
'comments' => $this -> input -> post('comments'),
);
if ($insert = $this -> staff_model -> session($arrData)) {
redirect('staff_controller/signin_info');
} else {
$this -> studentlogin();
}
型號:
function session($arrData) {
$null = NULL;
$sql2 = "INSERT INTO session (anum, first, last, why, aidyear, signintime, studentcomments)
VALUES (?, ?, ?, ?, ?, ?, ?)";
$insert = $this -> db -> query($sql2, $arrData);
return $insert;
}
當然可以用相同的字段名稱,你可以傳遞一個數組到模型。但你需要發佈你的錯誤,並顯示你的嘗試。 – Wolf 2013-02-22 03:42:25
編輯原始帖子 – RaGe10940 2013-02-22 03:49:27