任何人帮助我,请!在我的项目中,我有锁定记录的交易:
namespace App\Console\Commands;
use Illuminate\Console\Command;
class Testing extends Command {
protected function handling()
{
DB::beginTransaction();
try {
$posts = Posts::lockForUpdate()->find(1);
//run step 1
//run step 2
//run step 3
} catch (\Exception $e) {
DB::rollback();
}
}
}
就我而言,当它运行时,我从命令中调用它:
php artisan test:run
...
running step 1
...
...
running step 2
..
..
Ctrl C
-> quit command.
事务不会永远提交和锁定记录。
我可以在命令强制退出时提交事务吗?