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

Added Db::beforeExecuting() to register a hook which to be run just before a database query is executed. #4908

Merged
merged 6 commits into from
Jul 8, 2022
Merged

Conversation

huangdijia
Copy link
Member

@huangdijia huangdijia commented Jul 7, 2022

Db::beforeExecuting(function($query, $bindings, $connection) {
    // your logic
});

Example:

Db::beforeExecuting(function($query, $bindings, $connection) {
    if (Str::startsWith($query->sql, 'delete') && !Str::contains($query->sql, 'where')) {
        throw new Exception('Lost the condition!');
    }
});

@limingxinleo limingxinleo changed the title Adds Db::beforeExecuting() Added Db::beforeExecuting() to register a hook which to be run just before a database query is executed. Jul 8, 2022
@limingxinleo limingxinleo merged commit 13ab808 into hyperf:master Jul 8, 2022
@huangdijia huangdijia deleted the adds-db-before-executing branch July 8, 2022 05:12
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

2 participants