We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Oracle UTF8

Hi.

I have a problem working with oracle, I've got everything running but the charset. My config looks like this:

'orcdatabase' => array( 'dbname' => '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.X.XX)(PORT = 1521)))(CONNECT_DATA = (SERVICE_NAME = xe)))', 'username' => 'user', 'password' => 'password', 'options' => [PDO::ATTR_CASE => PDO::CASE_LOWER, PDO::ATTR_PERSISTENT => TRUE], ),

And it works. If I add the option (right below password, as seen here https://forum.phalcon.io/discussion/378/oracle-database-connection-error)

'charset' => 'AL32UTF8',

Or

'charset' => 'UTF8',

The app immeaditely breaks, and nothing gets written in the error log. I checked the oracle database and the charset is set to AL32UTF8 and supports spanish characters

Any help will be much appreciated

Thanks.

Ronald



3.6k
Accepted
answer

Ok, I figured it out. I'm writing it here in case someone else is looking for this.

What I needed to do was set the charset for the Oracle instant client, to do this, You can add them to the apache envvars or if your using php-fpm, the fpm script, like this:

ORACLE_HOME=/opt/oracle/instantclient NLS_LANG=SPANISH_SPAIN.AL32UTF8 NLS_TIMESTAMP_FORMAT="YYYY-MM-DD HH24:MI:SS" NLS_DATE_FORMAT="YYYY-MM-DD" NLS_DATE_LANGUAGE=SPANISH NLS_TIME_FORMAT="HH24:MI:SS" export ORACLE_HOME NLS_LANG NLS_TIMESTAMP_FORMAT NLS_TIME_FORMAT NLS_DATE_LANGUAGE NLS_DATE_FORMAT

Obviously you have to change the values to whatever you need. Hopefully It will help someone else.