zendframework / zend-db

Db component from Zend Framework
BSD 3-Clause "New" or "Revised" License
101 stars 122 forks source link

\Zend\Db\Adapter\Driver\Pdo\Connection::rollback error #385

Closed sorkl closed 4 years ago

sorkl commented 5 years ago

https://github.com/zendframework/zend-db/blob/4c68f2c33beb76d63a59c5bd5e6c96c9763966d7/src/Adapter/Driver/Pdo/Connection.php#L345 the function code like bellow maybe more better

    public function rollback()
    {
        if (!$this->isConnected()) {
            throw new Exception\RuntimeException('Must be connected before you can rollback');
        }

        if (!$this->inTransaction()) {
            throw new Exception\RuntimeException('Must call beginTransaction() before you can rollback');
        }

        if (0 === $this->nestedTransactionsCount) {
            $this->resource->rollBack();
            $this->nestedTransactionsCount = 0;
        }

        return $this;
    }
michalbundyra commented 5 years ago

@sorkl Would you like submit PR with the change and unit test? Thanks!

usuyukiso commented 5 years ago

I have similar issue
Must call beginTransaction() before you can rollback In Zend\Db\Adapter\Driver\Pdo\Connection.php line 353. Even though it was transaction. Also checked that it works with php 5.6, but fails with php7.2

I use libraries: zendframework/zend-db 2.10.0 zendframework/zend-stdlib 3.2.1

michalbundyra commented 4 years ago

See: #390. Closing as "won't fix".