Last active
May 14, 2019 19:56
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// General error: 2014 Cannot execute queries while other unbuffered queries are active | |
\DB::getPdo()->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true); |
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
Still getting below error after setting your suggestion:
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_QUERY attribute. (SQL: START TRANSACTION)