mardi 8 septembre 2020

Why is an alter database statement causing "General error: 2014 Cannot execute queries while other unbuffered queries are active."

I'm running a laravel (5.5) migration trying to change database default charset and collation:

<?php
use Illuminate\Database\Migrations\Migration;

class Utf8mb4Migration extends Migration
{
    public function up()
    {
        DB::statement(
            "ALTER DATABASE db_name CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_520_ci';"
        );
    }

    public function down()
    {
        \DB::statement(
            "ALTER DATABASE db_name CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';"
        );
    }
}

When running this (through php artisan migrate) I get the error message:

  SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active.  Consider using PDOStatement::fetchAll().    
  Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QU  
  ERY attribute. (SQL: ALTER DATABASE studi_drupal CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_520_ci';)                                         

Could anyone explain why I have other unbuffered queries?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire