Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MatteoOreficeIT/4e4f117d1efbbebb43c86e80749cf61c to your computer and use it in GitHub Desktop.
Save MatteoOreficeIT/4e4f117d1efbbebb43c86e80749cf61c to your computer and use it in GitHub Desktop.
How to set PDO attributes ( PDO::setAttributes ) Laravel:5.4.* , for example MYSQL_ATTR_USE_BUFFERED_QUERY
<?php
// General error: 2014 Cannot execute queries while other unbuffered queries are active
\DB::getPdo()->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true);
@ricardosierra
Copy link

I using laravel 5.8 and get the same error:

string(82) "Executando /var/www/html/libs/playground/resources/sql/patches/034.savedheader.sql"                                                                                                  
/var/www/html/database/migrations/2012_04_20_233207_init_playgrounds.php:79:                                                                                                                     
string(130) "CREATE TABLE herald_savedheader (                                                                                                                                                   
  phid varchar(64) binary not null primary key,                                                                                                                                                  
  header varchar(255) not null                                                                                                                                                                   
) ENGINE=InnoDB;                                                                                                                                                                                 
"                                                                                                                                                                                                
                                                                                                                                                                                                 
   Illuminate\Database\QueryException  : SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active.  Consider using PDOStatement::fetchAll().  Altern
atively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. (SQL: CREATE TABLE herald_savedheader 
(                                                                                                                                                                                                
  phid varchar(64) binary not null primary key,                                                                                                                                                  
  header varchar(255) not null                                                                                                                                                                   
) ENGINE=InnoDB;                                                                                                                                                                                 
)    

My migration code:

                var_dump($mysql);
                DB::execute($mysql);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment