laravel-sql-logger
laravel-sql-logger copied to clipboard
fix: modify replaceBindings logic to fit current laravel implementation.
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)