Home  >  Article  >  Backend Development  >  mysql 插入gzcompress后的数据总是 ‘x’,为什么解决办法

mysql 插入gzcompress后的数据总是 ‘x’,为什么解决办法

WBOY
WBOYOriginal
2016-06-13 13:46:48762browse

mysql 插入gzcompress后的数据总是 ‘x’,为什么
如题,我用php,将一个数组serialize后,在gzcompress,然后,将处理完的数据insert into到mysql中,可是在查看时,却发现,存入的数据总是x,为什么啊。而且,serialize和gzcompress都绝对没问题,在插入时还专门调试,插入语句也无错,可是,这个数据插入后,总是x。
求各路神仙不吝赐教。叩首拜谢。

------解决方案--------------------
字符问题压缩后的字符可能数据库当成乱码
插入前编码读取解码
base64_encode()//编码
base64_decode()//解码
------解决方案--------------------
serialize 后要注意特殊字符的转义
使用 gzcompress 则必须保证字段是二进制类型

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn