Hey all,
I'm trying to determine how I can have my Model rollback a transaction it made
on a DB table when the calling Controller fails to send a confirmation mail
afterwards. What is good practice? Am I approaching this in the wrong way
perhaps? Should I send the Mail from within the Model? That just doesn't feel
right. I'ld love to read your suggestions. Thank you in advance.
In short this is what happens now in pseudo code (please read the comments
inside the first catch, where I try to convey my point):
== Controller ==
Controller->signup()
{
if( true == Model->signup() )
{
try
{
Mail->send()
}
catch( Exception )
{
// seems stupid to have the Model roll back the transaction from here, no?
}
}
else
{
// do something when Model->signup() failed
}
}
== Model ==
Model->signup()
{
ModelDbTable->startTransaction()
try
{
ModelDbTable->insert()
ModelDbTable->commit()
return true
}
catch( Exception )
{
ModelDbTable->rollBack()
return false
}
}
Cheers
_________________________________________________________________
De leukste online filmpjes vind je op MSN Video!
http://video.msn.com/video.aspx?mkt=nl-nl