CI3

CI3 트랜잭션 (transaction)

수수깡깡 2022. 9. 30. 18:42
728x90
반응형

# 트랜잭션 시작

$this->db->trans_start();


# 트랜잭션 완료

$this->db->trans_complete();

#트랜잭션 엄격모드 비활성화

$this->db->trans_strict(false);

 

#트랜잭션 수동처리

$this->db->trans_begin();

$this->db->query("YOUR QUERY");

if  ($this->db->trans_status() === FALSE){
        $this->db->trans_rollback();
} else {
        $this->db->trans_commit();
}

 

# CI3 & CI4 Transaction

처리 CI3 CI4
트랜잭션 시작 trans_start() transStart()
트랜잭션 완료 trans_complete() transComplete()
트랜잭션 엄격모드 비활성화 trans_strict(false) transStrict(false)
결과 상태 trans_status() transStatus()
롤백 trans_rollback() transRollback()
커밋 trans_commit() transCommit()
비활성화 trans_off() transOff()

 

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class BoardModel extends CI_Model
{
    function test()
    {
    	$this->db->trans_start();
        $this->db->query("");
        $this->db->trans_complete();
    }
    
    function test2()
    {

        $this->db->trans_begin();
        $this->db->query("");

        if ($this->db->trans_status() === FALSE) {
            $this->db->trans_rollback();
        } else {
            $this->db->trans_commit();
        }
    }
}
728x90
반응형