PHP – MySQLi and Long text fields

By pafel, February 26, 2015

What happen today is that I spend at least 6 hours searching for a problem in the mysqli package of php. Found out that there is a bug in the component itself. What actually happen is that when you are using the mysqli in an application that do not have in its database longtext or blob columns in any of the tables you will never have a problem. Once you try reading from a table that have longtext column you will see an error for trying allocating a lot of memory.

I really spend a lot of time, because in the project which i was doing the change this is a core part. I knew that the database layer we had there was reliable and bug free. So most of my attention was not digging in the mysqli part.

Finally I found this bug here: https://bugs.php.net/bug.php?id=51386 and changed some stuff in our library and BOOM everything start working without any problem.

What is the conclusion:

  1. First I think you shouldn’t have a big reason of using longtext columns
  2. Always do $mysqli->store_result(); before $mysqli->bind_results() function
  3. and finally you shouldn’t have a reason of using longtext fields in your tables 🙂

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *