Last active
May 8, 2025 16:00
-
-
Save medeirosinacio/96fbef892c9aac3e4479a4126a356aa4 to your computer and use it in GitHub Desktop.
toRawSql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function toRawSql(string $query, array $bindings = []): string | |
{ | |
foreach ($bindings as $binding) { | |
if (is_string($binding)) { | |
$binding = addslashes($binding); | |
$binding = "'{$binding}'"; | |
} | |
$pos = strpos($query, '?'); | |
if ($pos !== false) { | |
$query = substr_replace($query, (string) $binding, $pos, strlen('?')); | |
} | |
} | |
return $query; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment