我有一个简单的PHP网络,通过文件上载接收icon图像,并在MEDIUMBLOB栏中储存。
在我的机器上(Windows)加上2台六氯环己烷服务器,这套机器可操作。 在第三台六氯环己烷服务器上,插入的图像被腐蚀:在选取后无法读取,而由MySQL公司(MySQL)功能报告的栏目数据长度大约比上载文档的尺寸高出40%。
(每个服务器连接MySQL的一个单独案例)
Of course, this leads me to think about encoding and character set issues. BLOB columns have no associated charsets, so it seems like the most likely culprit is PDO and its interpretation of the parameter value for that column.
- I ve tried using bindValue with PDO::PARAM_LOB, to no effect.
- I ve verified that the images are being received on the server correctly (i.e. am reading them post-upload with no problem), so it s definitely a DB/PDO issue.
- I ve searched for obvious configuration differences between the servers, but I m not an expert in PHP configuration so I might have missed something.
插入法则大致如下:
$imagedata = file_get_contents($_FILES["icon"]["tmp_name"]);
$stmt = $pdo->prepare( insert into foo (theimage) values (:theimage) );
$stmt->bindValue( :theimage , $imagedata, PDO::PARAM_LOB);
$stmt->execute();
任何帮助都将得到真正的赞赏。
www.un.org/Depts/DGACM/index_spanish.htm 错失的服务器上的MySQL焦炭 is是8ut;它给他人留下了1.。
The problem is "solved" by adding PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES latin1 COLLATE latin1_general_ci"
to the PDO constructor.
这似乎如a bug对我设计不好:为什么linkion<>>/em>的果园对双轨数据有任何影响,特别是当它被确认为与PARAM_LOB的双亲还是PDO?
Note that the DB tables are defined as latin1 in all cases: it s only the servers default charsets that are inconsistent.