unset($this->{$object->model});with this one:
$this->{$object->model}->clear();This should fix the problem, while still clearing out the related object.
UPDATE Question:
What version of PHP are you running? I tested it on mine, and PHP 5.2.6 had no problem calling the __get method after an unset.UPDATE 2
One more: you actually have a mistake in your example code! You are calling sch->school, but you mean sch->student. That’s your error.
I actually don’t have that line in my datamapper file (1.6.0). And this isn’t my actual situation. I just quoted it instead of saying the same thing over. My code is actually:
$cl = new Client();
$cl->get_by_id(1);
$cl->payment->get(); // Throws the errorAnd I’m running 5.2.8. Maybe that’s a problem?