|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-04-16 08:46 UTC] 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.
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 14:00:01 2025 UTC |
$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?OK. previous example also working witchout this code: $pdo->exec('SET CHARACTER SET utf8'); How use UTF-8 and blob columns?Sorry once again. Works when $pdo->exec('SET CHARACTER SET utf8'); is commented.