PDO LOB Insert Loses Bytes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
php5 (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: php5-mysql
When inserting an 8262 byte image into the database using pdo lobs on ubuntu, only 7966 bytes are inserted. All 8262 bytes are inserted with the same script on windows. Note, debian does the same thing as ubuntu.
Create a mySQL table called files in a database called play with this structure:
CREATE TABLE `files` (
`fileID` int(10) unsigned NOT NULL auto_increment,
`type` varchar(50) collate utf8_unicode_ci NOT NULL default '',
`data` blob NOT NULL,
PRIMARY KEY (`fileID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=
Put an image in a web directory.
Put this script in the same directory
<?php
/*this works fine*/
$imagesize = getimagesize('dm color logo copy.gif');
$fp = fopen('dm color logo copy.gif', 'rb');
/**
* When Ubuntu inserts images into the database using pdo lobs, it cuts them off.
* This same script works perfectly on Windows.
* On Ubuntu, a 8262 byte image turns into 7966 bytes in the database
* On Windows, it is stored with the correct size.
*/
$db = new PDO('mysql:
$prepared = $db->prepare(
$prepared-
$prepared-
$prepared-
/*this works fine*/
$id = $db->lastInsert
/*From other tests, this works fine on ubuntu*/
$prepared = $db->prepare(
$prepared-
$prepared-
$prepared-
$prepared-
$prepared-
header(
echo $lob;
?>
This script works on windows. It does not work on Ubuntu Feisty. It also does not work on MediaTemple's Grid Server which runs some version of Debian (which is where I originally discovered the problem).
For examples, see http://
(or look at http://
See http://
I found this also happens on OS X, so submitted to PHP as bug #42588