laravel-sql-logger icon indicating copy to clipboard operation
laravel-sql-logger copied to clipboard

fix: modify replaceBindings logic to fit current laravel implementation.

Open chris-lee-lb opened this issue 1 year ago • 0 comments

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 avatar Jul 01 '23 03:07 chris-lee-lb