Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Transaction callback #1045

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

tianyiw2013
Copy link
Contributor

@tianyiw2013 tianyiw2013 commented May 28, 2022

Added Method:

  • onActionCommitted
  • onActionRolledBack
  • onActionFinished

Added Test:

  • ActionTest::testActionCommit
  • ActionTest::testActionRollBack

Demo:

$medoo = new Medoo(...);
$medoo->action(function (Medoo $medoo) {
    $medoo->onActionCommitted(function (Medoo $medoo) {
        echo 'Action Committed', PHP_EOL;
        // For example: Stores the user's Avatar in the storage when the transaction is executed successfully, 
    });

    $medoo->onActionRolledBack(function (Medoo $medoo) {
        echo 'Action RolledBck', PHP_EOL;
        // For example: Delete the temporary file when the transaction fails.
    });

    $medoo->onActionFinished(function (Medoo $medoo, bool $commited) {
        echo 'Action Finished', PHP_EOL;
    });

});

My English is very poor. Please correct any grammar mistakes. thanks

@tianyiw2013
Copy link
Contributor Author

ping @catfan
Any questions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant