只是为了澄清所有答案在这里工作完美无瑕!自他首次发布以来,我选择了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