We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Forcing model::save() to return false

I am wrapping the save() action of a model in an internal, manual transaction. The transaction starts in beforeSave() and commit/rollback is in afterSave().

Even if I rollback the transaction in afterSave(), save() still returns true. Is there any way for me to override this?

do you try any way to fix with model events?

afterSave() can't stop the save operation because it's executed after the save (hence the name). I know save() returns after afterSave() is run - I'm just not sure if I can influence what save() returns.



32.3k
Accepted
answer

I think you have to overwrite save()and use in a common "base" model...

I think you have to overwrite save()and use in a common "base" model...

I don't know why I didn't think of that. Thanks.