add to_sql
This commit is contained in:
parent
5f3cb2fbea
commit
35d6795c2b
|
|
@ -227,3 +227,19 @@ function json_fail($message, $data = []): array
|
|||
];
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (!function_exists('to_sql')) {
|
||||
/**
|
||||
* @param mixed $builder
|
||||
* @return string|string[]|null
|
||||
*/
|
||||
function to_sql($builder)
|
||||
{
|
||||
$sql = $builder->toSql();
|
||||
foreach ($builder->getBindings() as $binding) {
|
||||
$value = is_numeric($binding) ? $binding : "'" . $binding . "'";
|
||||
$sql = preg_replace('/\?/', $value, $sql, 1);
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue