Php 8.3 No active Transaction in Laravel 8

56 Views Asked by At

Once it reaches DB::commit, it throws an error. However, if I comment out the Schema::table code, it works in PHP 8.3. In PHP 7.3, it still works as expected.

try {
    DB::beginTransaction();
  // performing some model::create() operations 
    if(!empty($table)){
        Schema::table($table, function (Blueprint $table) use ($newProfileField) {
            $column_type = isset($newProfileField->fieldType) ? $newProfileField- >fieldType->sql_column_type : 'string';
            $table->$column_type($newProfileField->field_name)->nullable();
        });
    
}

    DB::commit();
}
catch(Exception $ex) {
   DB::rollback();
}

This is happening once I upgraded my PHP version to 8.3
PDOException. There is no active transaction.

0

There are 0 best solutions below