0
我有5個輸入框,當用戶填寫的5個領域,並擊中提交,我們需要存儲的數據庫插入數據
爲此,我有這樣的代碼在我的控制器
public function send()
{
$this->loadmodel('Invitefriend');
$this->request->is('post');
$this->Invitefriend->create();
$this->loadModel('Student');
$id = $this->userValue['Student']['id'];
$contact = $this->userValue['Student']['phone'];
$emails= $this->data['Invitefriends'];
$currentDate=date('Y-m-d',strtotime($this->currentDate));
$email_count = count($emails);
for($i=1;$i<=$email_count;$i++)
{
$email = $emails['email'.$i];
$this->Invitefriend->save(array("ref_student_id"=>$id, "ref_contact"=>$contact, 'email'=>$email, 'date'=>$currentDate));
}
}
與只將最後一個字段值插入到數據庫中,但我需要將所有5個字段存儲到數據庫中。在我的代碼中是否有任何錯誤?