Doctrine\DBAL\Connection::setRollbackOnly PHP Method

setRollbackOnly() public method

Marks the current transaction so that the only possible outcome for the transaction to be rolled back.
public setRollbackOnly ( ) : void
return void
    public function setRollbackOnly()
    {
        if ($this->_transactionNestingLevel == 0) {
            throw ConnectionException::noActiveTransaction();
        }
        $this->_isRollbackOnly = true;
    }

Usage Example

 public function testSetRollbackOnlyNoActiveTransaction_ThrowsException()
 {
     $this->setExpectedException('Doctrine\\DBAL\\ConnectionException');
     $this->_conn->setRollbackOnly();
 }