Help with UTF8 and eZDB:instance problem needed

Author Message

Bojan S

Wednesday 13 February 2008 9:54:19 am

Hi,

I'm developing contribution for eZ Publish ver. 4.0. The problem is displaying of greman chars.
When I use code:

$db =& eZDB::instance();  
$query = "SELECT * FROM ...";
$ResultArray =& $db->arrayQuery( $query );
$out .= $ResultArray[0][$language];

The output is : Französisch.

When i replace the code above with this code:

mysql_connect('localhost', 'admin', '*****');
mysql_select_db('****');
$row = mysql_fetch_array(mysql_query("SELECT * FROM ...")); 
$out .= $row['$language']); 

The output is: Französisch.

Why first example doesn't work?

Thanks,
b_segic

Björn [email protected]

Wednesday 13 February 2008 2:29:26 pm

try

var_dump( $ResultArray );

or

$out .= $ResultArray[0]['language'];

Looking for a new job? http://www.xrow.com/xrow-GmbH/Jobs
Looking for hosting? http://hostingezpublish.com
-----------------------------------------------------------------------------
GMT +01:00 Hannover, Germany
Web: http://www.xrow.com/

Piotrek Karaś

Wednesday 13 February 2008 9:54:02 pm

There's too little context, but that's looks like invalid connection encoding was used to input the data or is skipped when connecting. Normally, before you work with UTF8 DB, you should call 'SET NAMES utf8' query (this is done automatically by eZ Publish db libs, I believe). When you establish your own connection and send query, it's most probably latin encoding by default, which is why your data seems fine.

Hint: use PHPMyAdmin, choose any UTF-8-like language and utf8_general_ci collation (just in case) and look at the data.

PS. Also, not sure if those references are needed there...

Good luck!

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Kristof Coomans

Wednesday 13 February 2008 11:21:09 pm

When using eZDB::instance(), there should be no need anymore to do a "SET NAMES ..." because it's done by the mysql database plugin IF your eZ Publish site is correctly configured (in i18n.ini, [CharacterSettings] Charset=utf-8 and in site.ini [DatabaseSettings] Charset= ). In case you're using mysqli, there's a special function used to set the connection's character set: mysqli_set_charset(...). But in either way, it should be automatically done for you when using eZDB::instance().

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.