Laravel 5.5 where() 结果不是预期的

Laravel 5.5 where() result is not expected

Laravel 5.5 数据库代码:

DB::table('users')->where('company_id', 'ACB')->toSql()

我希望结果为

SELECT * FROM `users` where `company_id` = `ACB`

但是,我得到了以下结果;

select * from `users` where `company_id` = ?

我做错了什么? 谢谢

没事, toSql() 方法,只会显示带有绑定参数的查询。

如果要显示绑定,需要使用query->getBindings()

这是一个安全,防止SQL注入 Databuilder 使用带有问号占位符的准备好的语句。

看看this PHP docs