Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Nested transactions not worked #10447

Closed
Closed
@Grey2k

Description

@Grey2k

Migrated from laravel 5.0 to 5.1 and try to use nested transactions (MySQL)

Wile try to call \DB::beginTransaction(); in second time

here is an error
'SQLSTATE[HY000]: General error: 2030 This command is not supported in the prepared statement protocol yet (SQL: SAVEPOINT trans2)'

investigating here
https://github.com/laravel/framework/blob/5.1/src/Illuminate/Database/Connection.php#L509

/**
     * Start a new database transaction.
     *
     * @return void
     */
    public function beginTransaction()
    {
        ++$this->transactions;

        if ($this->transactions == 1) {
            $this->pdo->beginTransaction();
        } elseif ($this->transactions > 1 && $this->queryGrammar->supportsSavepoints()) {
            $this->statement(
                $this->queryGrammar->compileSavepoint('trans'.$this->transactions)
            );
        }

        $this->fireConnectionEvent('beganTransaction');
    }

think framework try to bind and execute params on that command
here https://github.com/laravel/framework/blob/5.1/src/Illuminate/Database/Connection.php#L381

public function statement($query, $bindings = [])
    {
        return $this->run($query, $bindings, function ($me, $query, $bindings) {
            if ($me->pretending()) {
                return true;
            }
             // CODE passes here
            $bindings = $me->prepareBindings($bindings);

            return $me->getPdo()->prepare($query)->execute($bindings);
        });
    }

Think its help to fix this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions