yii\db\Schema::setTransactionIsolationLevel PHP Method

setTransactionIsolationLevel() public method

Sets the isolation level of the current transaction.
See also: http://en.wikipedia.org/wiki/Isolation_%28database_systems%29#Isolation_levels
public setTransactionIsolationLevel ( string $level )
$level string The transaction isolation level to use for this transaction. This can be one of [[Transaction::READ_UNCOMMITTED]], [[Transaction::READ_COMMITTED]], [[Transaction::REPEATABLE_READ]] and [[Transaction::SERIALIZABLE]] but also a string containing DBMS specific syntax to be used after `SET TRANSACTION ISOLATION LEVEL`.
    public function setTransactionIsolationLevel($level)
    {
        $this->db->createCommand("SET TRANSACTION ISOLATION LEVEL {$level};")->execute();
    }

Usage Example

Example #1
0
 /**
  * @inheritdoc
  * @see http://www.cubrid.org/manual/91/en/sql/transaction.html#database-concurrency
  */
 public function setTransactionIsolationLevel($level)
 {
     // translate SQL92 levels to CUBRID levels:
     switch ($level) {
         case Transaction::SERIALIZABLE:
             $level = '6';
             // SERIALIZABLE
             break;
         case Transaction::REPEATABLE_READ:
             $level = '5';
             // REPEATABLE READ CLASS with REPEATABLE READ INSTANCES
             break;
         case Transaction::READ_COMMITTED:
             $level = '4';
             // REPEATABLE READ CLASS with READ COMMITTED INSTANCES
             break;
         case Transaction::READ_UNCOMMITTED:
             $level = '3';
             // REPEATABLE READ CLASS with READ UNCOMMITTED INSTANCES
             break;
     }
     parent::setTransactionIsolationLevel($level);
 }
All Usage Examples Of yii\db\Schema::setTransactionIsolationLevel