Skip to content

General error: 2014 Cannot execute queries while other unbuffered queries are active #6745

Closed
@Kezino

Description

@Kezino

Greetings!

I have faced the following problem: after my shared hosting provider upgraded PHP, I started to receive the following error:

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.

Is there a way to set the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY through the standard Symfony 2 configuration?

Activity

Kezino

Kezino commented on Jan 15, 2013

@Kezino
Author

Found the solution:

doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
        options:
            1002: "SET NAMES utf8"  #initial query
            1000: true              #PDO::MYSQL_ATTR_USE_BUFFERED_QUERY

Now it works well.

afranioce

afranioce commented on Mar 17, 2015

@afranioce

+1

jdemangeon

jdemangeon commented on Feb 25, 2016

@jdemangeon

+1

health901

health901 commented on Mar 30, 2016

@health901

not work for me

jdemangeon

jdemangeon commented on Mar 30, 2016

@jdemangeon

@health901 Which driver do you use ?

hectorprats

hectorprats commented on Jan 22, 2018

@hectorprats

Close your sql cursor like here:

$stmt = $this->container->get('doctrine.orm.entity_manager')->getConnection()->prepare($content);
$stmt->execute();
$stmt->closeCursor();

Then, you can use your conection to do more queries.

Otech2018

Otech2018 commented on Dec 18, 2020

@Otech2018

Illuminate\Database\QueryExceptionSQLSTATE[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: update chats set status ='2' WHERE sender_id = 6 and receiver_id = 15 and status = 1 )

I need help on this error

derrabus

derrabus commented on Dec 18, 2020

@derrabus
Member

@Otech2018: thank you for reaching out.

This tracker is meant for tracking bugs and feature requests. If you are looking for support, you'll get faster responses by using one of our official support channels:

See https://symfony.com/support for more support options.

NamiNasih

NamiNasih commented on May 25, 2021

@NamiNasih

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while there are pending result sets. Consider unsetting the previous PDOStatement

This error is always happens while there were two executions at a same time for example:

  1. CASE 1

    if(!$query->execute())

    die("SQL FAILED");
    

    else

    $query->execute(); // **DELETE THIS ONE**
    

Solution: Second execution is no needed, remove second one, the first execution is already executed.

  1. if the first case is not working, USE this Solution call this function after $query=$handler->prepare($sql);

    $query->closeCursor();

I hope this Solution is helpful

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @afranioce@jdemangeon@health901@derrabus@Kezino

        Issue actions

          General error: 2014 Cannot execute queries while other unbuffered queries are active · Issue #6745 · symfony/symfony