Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Kezino opened this issue Jan 15, 2013 · 9 comments

Comments

@Kezino
Copy link

Kezino commented Jan 15, 2013

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?

@Kezino
Copy link
Author

Kezino commented Jan 15, 2013

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.

@Kezino Kezino closed this as completed Jan 15, 2013
@afranioce
Copy link

+1

1 similar comment
@jdemangeon
Copy link

+1

@health901
Copy link

not work for me

@jdemangeon
Copy link

@health901 Which driver do you use ?

@hectorprats
Copy link

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
Copy link

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
Copy link
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
Copy link

NamiNasih commented May 25, 2021

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants