用pdo_oci 取数据报错或被截取 UTF-8 output gets truncated


Warning: PDOStatement::fetch() [<a href='pdostatement.fetch'>pdostatement.fetch</a>]: column 3 data was too large for buffer and was truncated to fit it in

问题,就是使用PDO_OCI 从Oracle 中取数据,报错或是数据被截取了,显示不完整。像这样……

column XXX data was too large for buffer and was truncated to fit it in XXX

那么有两种方案 

1 修改源码 oci_statement.c (估计很多人不敢动)


php-src 中有了一定解答-修改原文件,不过 修改 ext / pdo_oci / oci_statement.c 

531-535行 https://github.com/php/php-src/pull/59/files 

        col->precision = scale;
-       col->maxlen = data_size;
+       col->maxlen = ( data_size + 1 ) * sizeof(utext);
        col->namelen = namelen;
        col->name = estrndup((char *)colname, namelen);

这种方式进行修改。据说是有用的 但是看过https://github.com/php/php-src/pull/59  github上并没有被采纳,说明还是有一定的问题。

2 通过sql 处理 

那么,幸好 仔细读了读了找着了https://bugs.php.net/bug.php?id=35003 

We found a "solution" to get it work: select cast( tbl.description AS 
varchar2(300) )as desc FROM database.table tbl;

使用 oracle 的 cast()函数进行转换 ,这样就可以了 IT Work !

//--------------------------------------------------------------------  

其他:关于 utext 是个啥? 或许是吧,就是转ut8用的??

http://code.metager.de/source/xref/WebKit/Source/WebCore/icu/unicode/utext.h 

http://userguide.icu-project.org/strings/utext 

UText is a text abstraction facility for ICU

The intent is to make it possible to extend ICU to work with text data that is in formats above and beyond those that are native to ICU.

UText makes it possible to extend ICU to work with text that

  1. Is stored in UTF-8 or UTF-32 format.

  2. Is in strings that are stored in discontiguous chunks in memory, or in application-specific representations.

  3. Is in a non-Unicode code page


转载于:https://my.oschina.net/startphp/blog/195333

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值