0

I am upgrading a site from PHP 5.4 to 7.2 and the main thing I have to change is all the mysql_ commands to use mysqli. In one case, there is a page that, on the current, production site, queries a database and populates a table with the results as they come in. So the page loads up, but continues loading, with rows appearing in the table until there are no more matching results, at which point the page stops loading.

I am running a dev version locally and the only thing I have changed on this page is switching the mysql_ code to procedural-style mysqli, but now, the page totally blocks on loading until all the results are in, then the page appears with all the table rows populated. Can anybody point me to where I should look to re-create the current behavior? Is it a database setting? Something in mysqli? Any help is greatly appreciated.

  • 3
    I have never seen this behavior before except when using AJAX. PHP is a server-side language and usually does not send data back to the page until it has finished processing the full request. – War10ck Jun 19 '18 at 15:36
  • @War10ck Perhaps it bears mentioning that the code to query and populate the table is wrapped in a function, which is called when the page loads. I don't know if that makes a difference. –  Jun 19 '18 at 15:41
  • No, it doesn't. – yivi Jun 19 '18 at 15:42
  • Read about [Buffered and Unbuffered queries](http://php.net/manual/en/mysqlinfo.concepts.buffering.php) – Paul Spiegel Jun 19 '18 at 16:07
  • @PaulSpiegel I don't think that's it. There's no use of `mysql_unbuffered_query` in the original code. And when I try to run the `mysqli` as unbuffered I get an error so I don't think it was working that way. –  Jun 19 '18 at 16:59
  • Possible duplicate of [How to change mysql to mysqli?](https://stackoverflow.com/questions/1390607/how-to-change-mysql-to-mysqli) – Dharman Jul 12 '19 at 19:26
  • Instead of changing to mysqli you wrap them. Make `myapp_query` etc. and do a search/replace and make the wrappers by using the mysqli. Make a subclass of PDO classes and start using that instead with prepared statements. The second you do change code you also change the DB code to use the PDO subclass or make it a weekly dept hour where you rewrite some of the old stuff over time. – Sylwester Jul 12 '19 at 23:21

0 Answers0