[eluser]liebgott[/eluser]
Hi!!
I'm testing things with Datamapper and I'm using this code to save (and update). Works great when i change 'name', but in the join table adds another relation instead delete all first when i select one new relation.
Code:
$estudiante=new Student();
$estudiante->where('id', '17')->get();
$estudiante->name=$this->input->post('nombre');
foreach ($this->input->post('curso') as $key => $value) {
$curso = new Course();
$curso->get_by_name($value);
$estudiante->save($curso);
}
I mean, i have this in my join table
Code:
id_student | id_course
17 1
17 2
When i update from form selecting a different course, and only one (e.g., course with id 3) -->
Code:
id_student | id_course
17 1
17 2
17 3
instead of
Code:
id_student | id_course
17 3
What i'm doing wrong????
Thanks!!