使用eager loading和lockForUpdate的查询是否也会锁定急切加载的行?

时间:2014-05-29 15:08:49

标签: mysql laravel innodb eloquent

我正在使用Laravel并急于加载电子邮件表。使用以下查询,它会将电子邮件表与users表一起锁定吗?

$queue = Users::with('email')
                ->lockForUpdate()
                ->get()

1 个答案:

答案 0 :(得分:2)

不,它没有:您可以在查询后添加var_dump(DB::getQueryLog())以查看所有查询。 如果您想锁定电子邮件表,可以尝试

$queue = Users::with(array('email'=>function($query){
            $query->lockForUpdate();
    })->lockForUpdate()
    ->get()
相关问题