MySQL incomplete query result

A couple weeks ago we received a message from a client who had problems with his export tool. All the records are exported nicely in a CSV file but some fields where cutt off. The same what you get when you have a field configured as VARCHAR(100) and then insert some random string larger than 100 chars.

The exporting tool exports data from custom created forms, we where afraid that a lot of data was gone. But after some debugging and making a export in phpMyAdmin we know that the data was still there. The strange thing was that on our local development machines we could make the export and it was complete! We knew that it had something to do with a server or connection config.

Me and my college searched everywhere and after some possible fixes we found the solution:

Adding this line to our MySQL PDO connection config the issue was gone: “PDO::MYSQL_ATTR_MAX_BUFFER_SIZE => 16777216

To the developers that run in to the same problem, i hope you can find this solution faster than we did 😉