From:             dhall at wustl dot edu
Operating system: 
PHP version:      5CVS-2007-09-07 (snap)
PHP Bug Type:     PDO related
Bug description:  PDO LOB Insert Loses Bytes

Description:
------------
See Ubuntu Bug 137960
I have duplicated this compiling on Mac OS X with the latest CVS snapshot,
so I think its not a Debian/Ubuntu packaging bug.

Reproduce code:
---------------
<?php
$imagesize = getimagesize('dm color logo copy.gif');
$fp = fopen('dm color logo copy.gif', 'rb');

/**
 * On Linux/OS X, a 8262 byte image turns into 7966 bytes in the database
 * On Windows, it is stored with the correct size.
 */
$db = new PDO('mysql:host=localhost;dbname=play', 'db_username',
'db_password', array( PDO::MYSQL_ATTR_INIT_COMMAND=>'SET CHARACTER SET
utf8;', PDO::MYSQL_ATTR_MAX_BUFFER_SIZE=>4194304 ) );
$prepared = $db->prepare('INSERT INTO `files` (`type`,`data`) VALUES
(:type, :data)');
$prepared->bindParam(':type',$imagesize['mime'], PDO::PARAM_STR, 50);
$prepared->bindParam(':data', $fp, PDO::PARAM_LOB);
$prepared->execute();

$id = $db->lastInsertId();

$prepared = $db->prepare('SELECT `type`, `data` FROM `files` WHERE
`fileid` = :fileid');
$prepared->bindParam(':fileid',$id, PDO::PARAM_INT);
$prepared->execute();
$prepared->bindColumn(1, $type, PDO::PARAM_STR, 256);
$prepared->bindColumn(2, $lob, PDO::PARAM_LOB);
$prepared->fetch(PDO::FETCH_BOUND);
header("Content-Type: $type");
echo $lob;
?>

Expected result:
----------------
properly output image as on
http://cowsandmilk.homeip.net/pdolob/pdolobtest.php

Actual result:
--------------
image missing bytes as on http://cowsandmilk.net/pdolob/pdolobtest.php
(goes from 8262 bytes to 7966 bytes)

-- 
Edit bug report at http://bugs.php.net/?id=42588&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42588&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42588&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42588&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42588&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42588&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42588&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42588&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42588&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42588&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42588&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42588&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42588&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42588&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42588&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42588&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42588&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42588&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42588&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42588&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42588&r=mysqlcfg

Reply via email to