PHP 클래스 yii\db\Transaction

It is usually created by calling [[Connection::beginTransaction()]]. The following code is a typical example of using transactions (note that some DBMS may not support transactions): php $transaction = $connection->beginTransaction(); try { $connection->createCommand($sql1)->execute(); $connection->createCommand($sql2)->execute(); .... other SQL executions $transaction->commit(); } catch (\Exception $e) { $transaction->rollBack(); throw $e; }
부터: 2.0
저자: Qiang Xue ([email protected])
상속: extends yii\base\Object
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$db the database connection that this transaction is associated with.

공개 메소드들

메소드 설명
begin ( string | null $isolationLevel = null ) Begins a transaction.
commit ( ) Commits a transaction.
getIsActive ( ) : boolean Returns a value indicating whether this transaction is active.
getLevel ( ) : integer
rollBack ( ) Rolls back a transaction.
setIsolationLevel ( string $level ) Sets the transaction isolation level for this transaction.

메소드 상세

begin() 공개 메소드

Begins a transaction.
public begin ( string | null $isolationLevel = null )
$isolationLevel string | null The [isolation level][] to use for this transaction. This can be one of [[READ_UNCOMMITTED]], [[READ_COMMITTED]], [[REPEATABLE_READ]] and [[SERIALIZABLE]] but also a string containing DBMS specific syntax to be used after `SET TRANSACTION ISOLATION LEVEL`. If not specified (`null`) the isolation level will not be set explicitly and the DBMS default will be used. > Note: This setting does not work for PostgreSQL, where setting the isolation level before the transaction has no effect. You have to call [[setIsolationLevel()]] in this case after the transaction has started. > Note: Some DBMS allow setting of the isolation level only for the whole connection so subsequent transactions may get the same isolation level even if you did not specify any. When using this feature you may need to set the isolation level for all transactions explicitly to avoid conflicting settings. At the time of this writing affected DBMS are MSSQL and SQLite. [isolation level]: http://en.wikipedia.org/wiki/Isolation_%28database_systems%29#Isolation_levels

commit() 공개 메소드

Commits a transaction.
public commit ( )

getIsActive() 공개 메소드

Returns a value indicating whether this transaction is active.
public getIsActive ( ) : boolean
리턴 boolean whether this transaction is active. Only an active transaction can [[commit()]] or [[rollBack()]].

getLevel() 공개 메소드

부터: 2.0.8
public getLevel ( ) : integer
리턴 integer The current nesting level of the transaction.

rollBack() 공개 메소드

Rolls back a transaction.
public rollBack ( )

setIsolationLevel() 공개 메소드

This method can be used to set the isolation level while the transaction is already active. However this is not supported by all DBMS so you might rather specify the isolation level directly when calling Transaction::begin.
또한 보기: http://en.wikipedia.org/wiki/Isolation_%28database_systems%29#Isolation_levels
public setIsolationLevel ( string $level )
$level string The transaction isolation level to use for this transaction. This can be one of [[READ_UNCOMMITTED]], [[READ_COMMITTED]], [[REPEATABLE_READ]] and [[SERIALIZABLE]] but also a string containing DBMS specific syntax to be used after `SET TRANSACTION ISOLATION LEVEL`.

프로퍼티 상세

$db 공개적으로 프로퍼티

the database connection that this transaction is associated with.
public $db