I insert about 1.1 Mb of Data into a Mysql Field of type LONGBLOB. This is far away from the maximum supported length of a LONGBLOB field.
The insert seems to work.
If I do a strlen($data)
before inserting it returns 1059245.
If i do a query after inserting:
SELECT OCTET_LENGTH(`data`)...
It returns 1059245
But if i do
$stmt = $pdo->prepare("SELECT `data` FROM `tbl_mytable` WHERE `id` = :id LIMIT 1");
$stmt->bindValue(":id", $id, PDO::PARAM_INT);
$stmt->execute();
$data = $stmt->fetch(PDO::FETCH_ASSOC);
echo strlen($data['data']);
it returns 1048576
My data seems to be cutten after 1048576 bytes.
Why do I only receive the first 1048576 bytes of my data when doing a query?
Is it a PDO Configuration, something like max_fetch_length?
It was the MYSQL_ATTR_MAX_BUFFER_SIZE which is 1MB by default.
This fixed the issue:
$pdo->setAttribute(PDO::MYSQL_ATTR_MAX_BUFFER_SIZE, 1024*1024*50); // 50 MB
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With