I want to create a sort of datamapper library, where you'd do something like this:
$users = Users::getTable();
$users->add($newUser1);
$users->add($newUser2);
Now $users
contains 2 user records, but they aren't yet persisted to the database. To be efficient, I'd like to flush them all at once. I would like to have a flush()
method to do this (not an issue), but I'd also like for it to happen implicitly when the $users
table reference falls out of scope. Is there any reason I shouldn't do this in the destructor?