安装官方文档里写的事务使用:
use Illuminate\Support\Facades\DB;
DB::transaction(function () {
//这里写业务逻辑sql
});
报如下错误:
RuntimeException: A facade root has not been set. in E:\nginx\html\CenterApi\vendor\illuminate\support\Facades\Facade.php:218
百度了报错信息,在stackoverflow里找到了一些资料,但是看不太明白
https://stackoverflow.com/que...
找到问题了,项目代码目录bootstrap/app.php下要开启$app->withFacades()