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

fix: modify replaceBindings logic to fit current laravel implementation. #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chris-lee-lb
Copy link

Currently function replaceBindings logic is not same as Laravel (based this)

    public function bindValues($statement, $bindings)
    {
        foreach ($bindings as $key => $value) {
            $statement->bindValue(
                is_string($key) ? $key : $key + 1,
                $value,
                match (true) {
                    is_int($value) => PDO::PARAM_INT,
                    is_resource($value) => PDO::PARAM_LOB,
                    default => PDO::PARAM_STR
                },
            );
        }
    }

And use is_numeric also will transform int string to int, which is unexpected.

PS: With currently PHP PDO implementation (url), when binding parameter is decimal, you can use PDO::PARAM_STR instead (there is no such PDO::PARAM_DECIMAL)

@chris-lee-lb chris-lee-lb force-pushed the develop branch 2 times, most recently from 279a2ab to d8c44c4 Compare July 1, 2023 04:23
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.

1 participant