Welcome Guest, Not a member yet? Register   Sign In
DataMapper ORM: Saving ids on relationship table
#1

[eluser]pfreitas[/eluser]
I've a employees, services and a employees_services table where I store the services one employee execute with their id and service id. I'm having trouble to save/update the services one employee execute...

Code:
// ...
$employee = new Employee;
$employee->from_array($this->input->post(null, true), array(
    // ... fields ...
));
$service = new Service;
    ->select('id')
    ->where_in('id', $this->input->post('services')) // ids from select-box
    ->get();
$employee->save(array('service' => $service->all));
This code is saving services, but if I try to deselect any option, it doesn't get deleted... I don't know where I'm doing wrong, what I've to do to insert/delete services based on select-box selection?

Thank you in advance!


Messages In This Thread
DataMapper ORM: Saving ids on relationship table - by El Forum - 10-16-2012, 05:03 AM
DataMapper ORM: Saving ids on relationship table - by El Forum - 10-16-2012, 06:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB