Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - PDO: MySQL's logged prepared statements include PS data

I use MySQL prepared statements in PHP through PDO to separate the query and the data, like:

CALL `celestial_object_view`(?, ?)

But the MySQL log shows

CALL `celestial_object_view`('1', '1')

Hence, I guess the data are actually merged into the query before being send to MySQL? It's not an issue for short data, but when inserting 10Mo of Blob data, the MySQL server screams about the exceeded max_allowed_packet.

How can I make PDO/PHP/MySQL consider the data separately from the PS so I can execute a short PS with tons of data, without reaching max_allowed_packet?

like image 373
Xenos Avatar asked Jan 29 '26 01:01

Xenos


1 Answers

There are two possible explanations for what you are seeing in the log.

  • an obvious one, by default PDO just emulates prepared statements, sending the regular SQL query to the server.
  • in case the real prepared statement has been used, the log entry you are seeing has been artificially conjured especially for the logging purposes, while prepared statement has been executed properly, with data sent separately.

So, just make sure that emulation mode is turned off, that you are binding your LOBs properly, and don't worry

like image 176
Your Common Sense Avatar answered Jan 31 '26 15:01

Your Common Sense



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!