When trying to delete a record I get this error:
Orm\FrozenObject [ Error ]: No changes allowed.
I have these two models:
class Model_Appointment extends Orm\Model
{
protected static $_properties = array('id', 'year', 'month', 'day', 'time', 'time_till');
protected static $_has_many = array('attendants');
}
class Model_Attendant extends Orm\Model
{
protected static $_properties = array('id', 'appointment_id', 'username');
protected static $_belongs_to = array('appointments');
}
My controller:
class Controller_Appointments extends Controller
{
public function action_delete($id = null)
{
$appointment = Model_Appointment::find($id);
if ( count($appointment->attendants) == 0 )
{
$appointment->delete();
}
}
}
I think you found a bug, your code looks a lot like the code I've used to test the Orm code but still I think it's a bug.
What happens is that you can "freeze" an object, which means it cannot be changed until you "unfreeze" it. This happens automaticly during saving/deleting to prevent loops between related objects. This error is shown when there's a relationship broken, that really shouldn't happen when there's no relations but that might just be the one case I didn't test properly.
I'll look into it.
Ok. I'm also getting an error when deleting with $attendant->delete();
When I remove $_belongs_to in Model_Attendant I don't get the error anymore.
Also a bug?