반응형
https://stackoverflow.com/questions/41392982/php-pdo-there-is-no-active-transaction
한줄요약 beginTransaction()의 경우 try catch문 밖에 위치해야한다.
==
The $connection->beginTransaction() must be outside of the try-catch block. When you're start the beginTransaction() in the try-block and your Database Operations throws an exception, the catch-block doesn't know something from an active transaction. So, you get the same error:
"There is no active transaction".
So the structure should be as well:
- Get the Connection.
- Start the Transaction with $connection->beginTransaction()
- Open the try-catch block.
The try-block contains the $connection->commit() after DB Operations.
The catch-block contains the $connection->rollback() before a throw Exception.
반응형
'기타 > PHP' 카테고리의 다른 글
strtotime 1달전 함수문제 (0) | 2024.11.11 |
---|---|
cURL error 60: SSL certificate (0) | 2022.11.25 |
'' // "" // 따옴표처리 (0) | 2020.03.31 |
fcm (0) | 2019.09.10 |
curl (0) | 2019.09.10 |