Laravel QueryBuilder到DB :: select [英] Laravel QueryBuilder to DB::select
问题描述
$ query-> get()
(由于行数和关系行数),它会停止并命中最大执行时间
。我显然不想只是增加时间...而且我不想重写所有的功能来使用原始查询(虽然我会的,如果我必须)。 我的问题是,有没有办法将 QueryBuilder
sql命令传递给 DB :: select
或 DB :: raw
。
我知道你可以使用 $ query-> toSql()
- 但是我缺少数据绑定值得,如果我可以得到这些,我可以在几秒钟内解决这个问题。
您可以通过调用查询构建器获取绑定 $ query-> getBindings()。
I've got an issue with a bottleneck in Laravel eloquent. When running the logic to build the query it's very quick and simple while using eloquent, however, when it finally comes to use $query->get()
(due to the number of rows, and the number of relational rows), it grinds to a halt and hits max execution time
. I obviously don't want to just increase the time... And I'd prefer not to re-write all my functions to use raw queries (although I will, if I have to).
My question is, is there a way to pass a QueryBuilder
sql command to DB::select
or DB::raw
.
I know you can use $query->toSql()
- but I'm lacking the data bound values, if I could get those, I could solve this in seconds.
You can get bindings from a query builder by calling $query->getBindings().
这篇关于Laravel QueryBuilder到DB :: select的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!