Salut à tout le monde
Comme vous le devinez je suis un débutant débutant et j'aimerai connaître la façon d'enregistrer toutes les notes(maths,français ...) d'un seul coup dans la table noteexes d'un élève de la table students
[img]http://www.casimages.com/img.php?i=131211051830682369.png[/img]
mon code:
[code]
class NoteexesController extends AppController {
public function add(){

   /* $notes =  $this->request->data;
    debug($notes);
    * 
    */
   if($this->request->is('post')){
        $this->Noteex->create();
   $data = array(
  'Noteex' => array(
    array(
      'session' => $this->request->data['Noteex']['session'],
      'notecc' => $this->request->data['Noteex'][0]['notecc'],
      'noteex' => $this->request->data['Noteex']['noteexca'],
      'students_id' => $this->request->data['Noteex']['student_id'],
      'matiers_id' => $this->request->data['Matiere'][0]['matiere_id']
    ),
    array(
      'session' => $this->request->data['Noteex']['session'],
      'notecc' => $this->request->data['Noteex'][1]['notecc'],
      'noteex' => $this->request->data['Noteex']['noteexca'],
      'students_id' => $this->request->data['Noteex']['student_id'],
      'matiers_id' => $this->request->data['Matiere'][1]['matiere_id']
    ),
    array(
      'session' => $this->request->data['Noteex']['session'],
      'notecc' => $this->request->data['Noteex'][2]['notecc'],
      'noteex' => $this->request->data['Noteex']['noteexca'],
      'students_id' => $this->request->data['Noteex']['student_id'],
      'matiers_id' => $this->request->data['Matiere'][2]['matiere_id']
    ),array(
      'session' => $this->request->data['Noteex']['session'],
      'notecc' => $this->request->data['Noteex'][3]['notecc'],
      'noteex' => $this->request->data['Noteex']['noteexca'],
      'students_id' => $this->request->data['Noteex']['student_id'],
      'matiers_id' => $this->request->data['Matiere'][3]['matiere_id']
    ),

  )
);
debug($this->Noteex);

if($this->Noteex->save($data)){
$this->Session->setFlash('les notes sont ajotées avec succé'); ;
}

    $this->set('matieres',$this->Noteex->Matiere->find('list'));
    $this->set('students',$this->Noteex->Student->find('list'));
   // $this->set('groups', $this->User->Group->find('list'));
     $this->set('prenoms',$this->Noteex->Student->find('list',array(
        'fields'=>'prenom'
    )));

} 

}
}
?>
[/code]
merci

Aucune réponse