Open winstonewert opened 1 year ago
Hi. I believe the statement is bound to the database at the server side. I believe the only reasonable thing we can do is to add a note in the docs.
I was able to solve it by manually preparing and closing my statement.
Another option is to invoke Conn::reset after use another_db
is executed.
Perhaps select_db
could reset the statement cache? You could also possibly identify "USE" statements and clear the cache if they are detected? I'm not sure either of those is worthwhile.
I have a case where I need to run the exact same query against a number of different databases within one MySQL instance. I did this by running "use database_name" follow by my actual query in a loop. Sadly, I just get the results from the first query back over and over. It looks like this is because the statement is cached after the first query and then reused. Using the
select_db
function does not solve the problem. I was able to solve it by manually preparing and closing my statement.