zendframework/zend-db

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

sorkl opened this issue · 3 comments

sorkl commented

public function rollback()

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;
    }

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

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

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