Commands out of sync; you can't run this command now [SOLVED] |
I'm trying to run a few queries in sequence and I keep getting the error Commands out of sync; you can't run this command now in my php logs.
I have read: https://stackoverflow.com/questions/4323...ommand-now, however I am not able to update /system/database/drivers/mysqli/mysqli_result.php I've tried: ``` $this->db->reset_query(); $this->db->close(); $this->db->initialize(); $this->db->reconnect(); mysqli_next_result( $this->db->conn_id ); $query->free_result(); ``` But they either give me the same error, or different errors which I will detail in the comments of my code. The way my code is organized- I have a make_query method that takes a bunch of search options and figures out which tables to join and fields to search based on those. Sometimes, I just want to count results, sometimes I want all of the resulting data, sometimes I just want distinct values for certain fields or to group by certain fields. So I call make_query with my options, and then decide what to select afterwards. I have also been saving my query text to report, so that users can see what query is being run. One interesting thing I have noted is that when I have no options set (ie there are no WHERE clauses in my SQL), I do not get this error and the multiple queries are able to run with no problem! Here is my code: Code: //Get rows from tblPlots based on criteria set in options array I'm not including the code for make_query because it is long and calls other functions, but it runs successfully the first time and outputs the SQL query I would expect. If it would be helpful, I can include that code as well. I'm not sure how to correctly call free_result() given that the CI documentation only gives an example using query('SQL QUERY'), so I'm not sure how to use free result in my scenario? Maybe that's the issue? Code: $query2 = $this->db->query('SELECT name FROM some_table'); Thank you for any help! |
Messages In This Thread |
Commands out of sync; you can't run this command now [SOLVED] - by xanabobana - 11-21-2022, 03:29 PM
RE: Commands out of sync; you can't run this command now - by InsiteFX - 11-22-2022, 01:25 AM
RE: Commands out of sync; you can't run this command now - by xanabobana - 11-22-2022, 12:54 PM
RE: Commands out of sync; you can't run this command now - by InsiteFX - 11-22-2022, 11:23 PM
RE: Commands out of sync; you can't run this command now - by xanabobana - 11-23-2022, 11:00 AM
RE: Commands out of sync; you can't run this command now - by InsiteFX - 11-24-2022, 01:32 AM
RE: Commands out of sync; you can't run this command now - by rodrigoguariento - 12-13-2024, 02:39 PM
RE: Commands out of sync; you can't run this command now - by InsiteFX - 12-13-2024, 09:17 PM
|