Re: Oracle PDO UTF-8 problem

[email protected] (Karsten Lehmann) Fri, 14 Jan 2011 08:36:40 +0100
Newsgroups php.pdo
Message-ID <[email protected]>
I found out that the error depends on the wrong character set of the 
Oracle database. In my case this was a Western Europe instance of the 
database. The same data on a UTF8 instance was displayed as excpected.

Am 13.01.2011 09:55, schrieb Karsten Lehmann:
> Hello
>
> I try to read a 2000 character long string out of database. The database
> is an oracle 10g Express Edition with UTF-8 character set. To read the
> string we use the PDO abstraction layer with oci-driver. If the 2000
> character contains one or more UTF-8 characters we get the problem that
> PDO truncate the result of the database, with the following message:
>
> Warning: PDOStatement::fetchAll() [pdostatement.fetchall]: column 5 data
> was too large for buffer and was truncated to fit it in
> C:\wamp\www\wp\bp.php on line 115
>
>
> The definition of the database column is
>
> TESTSTRING VARCHAR2(2000 CHAR)
>
> CHAR means that we can store up to 2000 characters independent from the
> encoding of the character (e.g. UTF8).
>
>
> I also init the PDO with UTF8
>
> $dbh = new PDO('oci:dbname=' . $db_name . ';charset=UTF8', $db_user,
> $db_pw);
>
>
> If i read the same string with java and JDBC-driver it works fine, so i
> can exclude a database error.
>
> How i have to configre PHP/PDO to be aware of the truncation of the
> result string?