I write (again... ;)) to the list because a little thing happen to me
this afternoon, wich seems really... Surprising in a first time (even if
I doubt that can be "fixed") and cause to me some headaches before
finding the reason.
Imagine such an example:
$users_table->getAdapter()->beginTransaction();
$user = $users_table->createRow();
// Things to do...
try {
$user->save();
users_table->getAdapter()->commit();
}
catch (Zend_Db_Exception $e) {
users_table->getAdapter()->rollback();
}
A call of echo $user->id; will display the temporary id given by the
save() method, regardless of the current transaction was or not
comited... It's not really worrying... Except when you keep the $user
object into session during a long signup procedure... If an exception
occured and the transaction rollback, object keep the "recorded" state,
and can't be saved later (exception is thrown in the _refresh method, as
no "parent row were found").
I just want to know if that fact is well knowned of Zend Framework's
users, or if I was the only one surprised of that behaviour. Any chance
that, in future versions, row objects will be aware of the current
transaction state ?
没有评论:
发表评论