doujiong3146 2016-01-08 08:18
浏览 41
已采纳

Laravel Query Builder到DB :: select

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.

  • 写回答

1条回答 默认 最新

  • doucan4873 2016-01-08 08:22
    关注

    You can get bindings from a query builder by calling $query->getBindings().

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符