0
모델을 업데이트해야하지만 모델 자체의 ID 대신 student_id를 사용하여 모델을 찾아야합니다.레코드를 업데이트하지만 레코드 이외의 값으로 읽음 ID
나는이 솔루션을 생각해 냈지만 더 좋은 방법이 있는지 궁금해하고 있었습니까? 거의
if (!empty($this->data)) {
// function that calculates score from answers in $this->data
$score = $this->OnlineExam->checkAnswers(2,$this->data);
// find the record
$record = $this->OnlineExam->find('first', array(
'conditions' => array('OnlineExam.student_id' => $this->Session->read('OnlineExam.studentId')),
'fields' => array('OnlineExam.id')));
// set the id and the score in the data array
$this->data['OnlineExam']['id'] = $record['OnlineExam']['id'];
$this->data['OnlineExam']['scoreB'] = $score;
// save the model
if($this->OnlineExam->save($this->data)) {
$this->redirect(array('controller' => 'OnlineExams', 'action' => 'page3'));
}
덕분에 .. 훨씬 더 – AlexBrand