ID: 47982 User updated by: markac at home dot pl Reported By: markac at home dot pl Status: Open Bug Type: PDO related Operating System: XP PHP Version: 5.2CVS-2009-04-16 (snap) New Comment:
Sorry, replace $avatar to $user->avatar from all. Function argument is an object $user, 'avatar' and 'id' is properties. Previous Comments: ------------------------------------------------------------------------ [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