Skip to content

DB::transaction does not work when using DB::connection()  #19715

@hfmikep

Description

@hfmikep
  • Laravel Version: 5.4.#
  • PHP Version: 7.1.5
  • Database Driver & Version: MySQL 5.6.36

Description:

DB::transactions do not work when using DB::connection()

Steps To Reproduce:

Create a non-default config for a mysql database.

Attempt to run the following code:

 DB::beginTransaction();

    try {

        DB::connection('newdb')->table('users')->where('id', 2)->update(['status' => 'VALIDATED']);
        throw new \Exception('Some new exception');
        DB::commit();

    } catch ( Exception $ex ){

        DB::rollBack();
    
}

The DB transaction is immediately committed at the update statement and can not be rolled back.

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