Bug #47982 [Asn->Opn]: PDO_mysql: Storing image binary data
| From: | uw@php.net | Date: | Tue, 11 May 2010 11:04:04 +0000 |
| Subject: | Bug #47982 [Asn->Opn]: PDO_mysql: Storing image binary data | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-150328@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=47982&edit=1
ID: 47982
Updated by: uw@php.net
Reported by: markac at home dot pl
Summary: PDO_mysql: Storing image binary data
-Status: Assigned
+Status: Open
Type: Bug
Package: MySQL related
Operating System: WinXP
PHP Version: 5.2CVS-2009-04-16 (snap)
-Assigned To: mysql
+Assigned To:
New Comment:
Not a MySQL specific issue. PDO general/PDO specification issue.
Previous Comments:
------------------------------------------------------------------------
[2009-08-25 14:04:35] uw@php.net
I don't call this a bug.
PDO::PARAM_LOB "can be either textual or binary in nature":
"At some point in your application, you might find that you need to
store "large" data in your database. Large typically means "around 4kb
or more", although some databases can happily handle up to 32kb before
data becomes "large". Large objects can be either textual or binary in
nature. PDO allows you to work with this large data type by using the
PDO::PARAM_LOB type code in your PDOStatement::bindParam() or
PDOStatement::bindColumn() calls. PDO::PARAM_LOB tells PDO to map the
data as a stream, so that you can manipulate it using the PHP Streams
API.", http://www.php.net/manual/en/pdo.lobs.php
PDO_MySQL threats PDO::PARAM_LOB like textual data. Textual data needs
to be escaped. This is what also happens if you use the PDO Prepared
Statmeent emulation, which has been a default for a long time. When
using the emulation, the column will be seen as textual data and be
escaped.
This, however, is not a MySQL specific problem. MySQL is affected
because it supports charsets and stuff. But every other PDO driver
supporting charsets is affected as well.
A proper fix would be to introduce PDO::PARAM_BLOB for use with binary
data. PDO::PARAM_BLOB should go into the PDO core. As changes to the
core can impact all drivers, a volunteer is needed to check and/or
update all drivers to get this PDO flaw fixed.
Ulf
------------------------------------------------------------------------
[2009-04-22 10:51:40] johannes@php.net
Thanks. Got it now reproduced using 5.2 as well as 5.3 (with both
libmysql and mysqlnd)
------------------------------------------------------------------------
[2009-04-21 18:48:05] markac at home dot pl
Only dependant on the SET NAMES.
------------------------------------------------------------------------
[2009-04-21 15:10:53] johannes@php.net
I'm not sure I correctly understand your both last messages. Is the
problem only dependant on the SET NAMES call or also on the server
version?
Thanks for clarification.
------------------------------------------------------------------------
[2009-04-16 13:33:16] markac at home dot pl
Sorry once again. Works when
$pdo->exec('SET CHARACTER SET utf8');
is commented.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/bug.php?id=47982
--
Edit this bug report at http://bugs.php.net/bug.php?id=47982&edit=1