📜  laravel 在没有绑定的普通 sql 中获取查询 - PHP 代码示例

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

代码示例1
/**
 * 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());
}