CI4
[코드이그나이터] 트랜잭션(Transactiion)
으누아빠
2020. 9. 7. 18:41
반응형
트랜잭션(Transactiion)
출처:
http://ci4doc.cikorea.net/database/transactions.html
$this->db->transStart();
$this->db->query('AN SQL QUERY...');
$this->db->query('ANOTHER QUERY...');
$this->db->query('AND YET ANOTHER QUERY...');
$this->db->transComplete();
// 엄격 모드가 사용 가능한 경우 여러 트랜잭션 그룹을 실행중인 경우 한 그룹이 실패하면 모든 그룹이 롤백
$this->db->transStrict(false);
트랜젝션 비활성화
$this->db->transOff();
$this->db->transStart();
$this->db->query('AN SQL QUERY...');
$this->db->transComplete();
// 트랜잭션을 수동으로 실행
$this->db->transBegin();
$this->db->query('AN SQL QUERY...');
$this->db->query('ANOTHER QUERY...');
$this->db->query('AND YET ANOTHER QUERY...');
if ($this->db->transStatus() === FALSE)
{
$this->db->transRollback();
}
else
{
$this->db->transCommit();
}