ID: 47982
Updated by: [email protected]
Reported By: markac at home dot pl
-Status: Open
+Status: Feedback
Bug Type: MySQL related
Operating System: XP
PHP Version: 5.2CVS-2009-04-16 (snap)
Assigned To: mysql
New Comment:
I wasn't able to reproduce the issue. Could you please give me the
mysql version (the server version as well as the version of the mysql
client library used (see phpinfo() output) and the table defintion of
your table. Thanks.
Previous Comments:
------------------------------------------------------------------------
[2009-04-16 09:37:03] markac at home dot pl
OK. previous example also working witchout this code:
$pdo->exec('SET CHARACTER SET utf8');
How use UTF-8 and blob columns?
------------------------------------------------------------------------
[2009-04-16 09:31:47] markac at home dot pl
$image = fopen('image.jpg','rb');
$sth->bindValue(':avatar', $image, PDO::PARAM_LOB);
Also not working, but when I remove this code:
$pdo->exec('SET CHARACTER SET utf8');
then is working in this example.
Any suggestion?
------------------------------------------------------------------------
[2009-04-16 08:56:23] [email protected]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
and mysql != PDO
------------------------------------------------------------------------
[2009-04-16 08:50:30] markac at home dot pl
Sorry, replace $avatar to $user->avatar from all. Function argument is
an object $user, 'avatar' and 'id' is properties.
------------------------------------------------------------------------
[2009-04-16 08:46:49] markac at home dot pl
Description:
------------
PDO adding extra bytes (F3 F3 F3 F3) to begining binary data.
I'm use SOAP extension to retrieving data from client. When I save data
to file or using MySQL directly, all is ok. When I use PDO to store the
same data to column (MySQL), PDO adding extra data and image is broken.
Reproduce code:
---------------
$server = new SoapServer('file.wsdl', array('cache_wsdl' =>
WSDL_CACHE_NONE));
/* Connect to an ODBC database using driver invocation */
$dsn = 'mysql:dbname=db;host=localhost;charset=UTF-8';
$user = 'root';
$password = '';
$pdo = new PDO($dsn, $user, $password);
$pdo->exec('SET CHARACTER SET utf8');
//NOT WORK! Adding Image is broken
$sth = $pdo->prepare('UPDATE users SET
avatar = :avatar
WHERE id = :id
');
//$avatar is server function argument. See
$server->addFunction('UpdateUser);
$sth->bindParam(':avatar', $avatar, PDO::PARAM_LOB);
$sth->bindParam(':id', $user->id, PDO::PARAM_INT);
return $sth->execute();
//THIS WORK!
file_put_contents('image.jpg', $user->avatar);
/* AND THIS WORK!
mysql_query('update users set avatar = "' .
addslashes($user->avatar) . '" where id = ' . $user->id);
*/
$server->addFunction('UpdateUser);
$server->handle();
Sorry for my english.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47982&edit=1