【发布时间】:2015-06-15 07:33:43
【问题描述】:
我有一些麻烦,因为我的查询在 from 子句之后没有 with (nolock) 指令。
因此,一些查询锁定数据库,然后没有人可以使用系统。
如何在 Eloquent & Query Builder 中使用 with (nolock)?
例如..在这个查询中:
return static::with('campaignType')
->where('active', 1)
->get();
我想要以下结果:
select
*
from campaigns with (nolock)
inner join campaign_types with (nolock) on campaign_types.id = campaigns.campaign_type_id
where campaigns.active = 1
【问题讨论】:
-
请发布一些代码供我们审核。如果 Laravel 不支持您要查找的内容,您可能还想查看 DB::raw 方法。
-
我很确定
DB::raw有效,但我想要一个雄辩的/查询构建器解决方案。只有在 eloquent 中没有选项时,我才尝试使用 raw。
标签: php sql sql-server laravel eloquent