📜  laravel 带参数的打印查询 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:46.301000             🧑  作者: Mango

代码示例4
/**
 * Combines SQL and its bindings
 *
 * @param \Eloquent $query
 * @return string
 */
public static function getEloquentSqlWithBindings($query)
{
    return vsprintf(str_replace('?', '%s', $query->toSql()), collect($query->getBindings())->map(function ($binding) {
        $binding = addslashes($binding);
        return is_numeric($binding) ? $binding : "'{$binding}'";
    })->toArray());
}