我遇到了一些麻烦,因为我的查询在 from
子句之后没有 with (nolock)
指令。
因此,一些查询锁定数据库,然后就没有人可以使用该系统了。
如何将 with (nolock)
与 Eloquent & Query Builder 一起使用?
例如..在这个查询中:
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
最佳答案
你可以像这样设置“with(nolock)”:
DB::table('campaigns')->lock('WITH(NOLOCK)')
关于php - Laravel Eloquent 和查询生成器 "with (nolock)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29546905/