Oracle PDO UTF-8 problem

Oracle PDO UTF-8 problem

am 13.01.2011 09:23:22 von 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?

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Oracle PDO UTF-8 problem

am 13.01.2011 10:27:31 von Kesavan Rengarajan

--0016368e2380827ba40499b6ee03
Content-Type: text/plain; charset=ISO-8859-1

Try increasing this: PDO::MYSQL_ATTR_MAX_BUFFER_SIZE

More info here: http://php.net/manual/en/ref.pdo-mysql.php
On Thu, Jan 13, 2011 at 7:23 PM, Karsten Lehmann wrote:

> 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?
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--0016368e2380827ba40499b6ee03--

Re: Oracle PDO UTF-8 problem

am 13.01.2011 10:42:09 von Karsten Lehmann

Doesn't work.

I got the following error after i set the parameter in the PDO construct

Fatal error: Undefined class constant 'MYSQL_ATTR_MAX_BUFFER_SIZE'

IMHO this is only a MYSQL parameter but i worked with oracle.

Am 13.01.2011 10:27, schrieb kesavan trichy rengarajan:
> Try increasing this: PDO::MYSQL_ATTR_MAX_BUFFER_SIZE
>
> More info here: http://php.net/manual/en/ref.pdo-mysql.php
> On Thu, Jan 13, 2011 at 7:23 PM, Karsten Lehmann wrote:
>
>> 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?
>>
>> --
>> PHP Database Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Query syntax error?

am 13.01.2011 15:33:10 von Harvey

Hello,

I have a query on a page that used to work fine, but is now generating an
error.

I assume that the version of php or mysql was updated on the webhost server
or something like that?

Here is the query:

select count(places_data.place_id) as areacount, boroughs.borough_name as
boroname, area.area_name as areaname, area.area_id as areaid
from places_data a
inner join boroughs b on a.area_fid = b.area_id
inner join area c on c.borough_fid = b.borough_id
where places_data.on_off_fid = 2
" . $cat_query . "
group by c.area_name
order by b.borough_name ASC, c.area_name ASC

And here is the error message:

Unknown column 'places_data.place_id' in 'field list'

But place_id is a field in places_data table.

Any ideas?

Thanks!

Harvey


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Query syntax error?

am 13.01.2011 15:51:32 von jose javier parra sanchez

you have renamed places_data table to 'a'

2011/1/13 Harvey :
> Hello,
>
> I have a query on a page that used to work fine, but is now generating an
> error.
>
> I assume that the version of php or mysql was updated on the webhost server
> or something like that?
>
> Here is the query:
>
> select count(places_data.place_id) as areacount, boroughs.borough_name as
> boroname, area.area_name as areaname, area.area_id as areaid
> from places_data a
> inner join boroughs b on a.area_fid = b.area_id
> inner join area c on c.borough_fid = b.borough_id
> where places_data.on_off_fid = 2
> " . $cat_query . "
> group by c.area_name
> order by b.borough_name ASC, c.area_name ASC
>
> And here is the error message:
>
> Unknown column 'places_data.place_id' in 'field list'
>
> But place_id is a field in places_data table.
>
> Any ideas?
>
> Thanks!
>
> Harvey
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: Query syntax error?

am 13.01.2011 17:39:05 von Harvey

Thanks, I got it working now, had to use the a/b/c thing a few times


-----Original Message-----
From: jose [mailto:jojapasa@gmail.com]
Sent: Thursday, January 13, 2011 9:52 AM
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] Query syntax error?

you have renamed places_data table to 'a'

2011/1/13 Harvey :
> Hello,
>
> I have a query on a page that used to work fine, but is now generating an
> error.
>
> I assume that the version of php or mysql was updated on the webhost
server
> or something like that?
>
> Here is the query:
>
> select count(places_data.place_id) as areacount, boroughs.borough_name as
> boroname, area.area_name as areaname, area.area_id as areaid
> from places_data a
> inner join boroughs b on a.area_fid = b.area_id
> inner join area c on c.borough_fid = b.borough_id
> where places_data.on_off_fid = 2
> " . $cat_query . "
> group by c.area_name
> order by b.borough_name ASC, c.area_name ASC
>
> And here is the error message:
>
> Unknown column 'places_data.place_id' in 'field list'
>
> But place_id is a field in places_data table.
>
> Any ideas?
>
> Thanks!
>
> Harvey
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Oracle PDO UTF-8 problem

am 14.01.2011 08:36:01 von Karsten Lehmann

I found out that the error depends on the wrong character set of the
Oracle Database. In my case this was a Western Europ instance of the
Database. The same data on a UTF8 instance was displayed as excpected.

Am 13.01.2011 10:42, schrieb Karsten Lehmann:
> Doesn't work.
>
> I got the following error after i set the parameter in the PDO construct
>
> Fatal error: Undefined class constant 'MYSQL_ATTR_MAX_BUFFER_SIZE'
>
> IMHO this is only a MYSQL parameter but i worked with oracle.
>
> Am 13.01.2011 10:27, schrieb kesavan trichy rengarajan:
>> Try increasing this: PDO::MYSQL_ATTR_MAX_BUFFER_SIZE
>>
>> More info here: http://php.net/manual/en/ref.pdo-mysql.php
>> On Thu, Jan 13, 2011 at 7:23 PM, Karsten Lehmann
>> wrote:
>>
>>> 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?
>>>
>>> --
>>> PHP Database Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Oracle PDO UTF-8 problem

am 14.01.2011 23:57:42 von Christopher Jones

Glad you resolved it.

Overall, I have to recommend the OCI8 extension over the unmaintained
(like much of PDO) PDO_OCI extension.

Chris

On 01/13/2011 11:36 PM, Karsten Lehmann wrote:
> I found out that the error depends on the wrong character set of the Oracle Database. In my case this was a Western Europ instance of the Database. The same data on a UTF8 instance was displayed as excpected.
>
> Am 13.01.2011 10:42, schrieb Karsten Lehmann:
>> Doesn't work.
>>
>> I got the following error after i set the parameter in the PDO construct
>>
>> Fatal error: Undefined class constant 'MYSQL_ATTR_MAX_BUFFER_SIZE'
>>
>> IMHO this is only a MYSQL parameter but i worked with oracle.
>>
>> Am 13.01.2011 10:27, schrieb kesavan trichy rengarajan:
>>> Try increasing this: PDO::MYSQL_ATTR_MAX_BUFFER_SIZE
>>>
>>> More info here: http://php.net/manual/en/ref.pdo-mysql.php
>>> On Thu, Jan 13, 2011 at 7:23 PM, Karsten Lehmann
>>> wrote:
>>>
>>>> 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?
>>>>
>>>> --
>>>> PHP Database Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>>>
>>
>
>

--
Email: christopher.jones@oracle.com
Tel: +1 650 506 8630
Blog: http://blogs.oracle.com/opal/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php