dougang1965
2017-06-08 04:23
浏览 249
已采纳

Laravel - PDO准备语句 - 在其他未缓冲的查询处于活动状态时无法执行查询

I am having trouble running the following prepared statement in Laravel:

$pdo = DB::connection()->getPdo();
$ps_TempTable_PushCsv = $pdo->prepare(
    "LOAD DATA LOCAL INFILE '123'
    INTO TABLE `123`
    CHARACTER SET utf8mb4
    FIELDS TERMINATED BY ','
    OPTIONALLY ENCLOSED BY '\"'
    LINES TERMINATED BY '\
'"
);
$ps_TempTable_PushCsv->execute();
$ps_TempTable_PushCsv->closeCursor();
$rowCount = $ps_TempTable_PushCsv->rowCount();

I get the following error:

[2017-06-08 03:41:35] local.ERROR: PDOException: 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.

This is the entry-point of my controller, so there are definitely no prior queries running.

What do?

Thanks

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题