用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 中取数据,报错或是数据被截取了,显示不完整。像这样……php

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

那么有两种方案 git

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


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

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

        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上并无被采纳,说明仍是有必定的问题。app

2 经过sql 处理 ide

那么,幸亏 仔细读了读了找着了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 !fetch

//--------------------------------------------------------------------  ui

其余:关于 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

相关文章
相关标签/搜索