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 Dieding@xrow.de

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.

eZ debug

Timing: Jan 31 2025 06:19:06
Script start
Timing: Jan 31 2025 06:19:06
Module start 'layout'
Timing: Jan 31 2025 06:19:06
Module start 'content'
Timing: Jan 31 2025 06:19:06
Module end 'content'
Timing: Jan 31 2025 06:19:06
Script end

Main resources:

Total runtime0.0120 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0047 588.2656151.2266
Module start 'layout' 0.00470.0022 739.492236.6797
Module start 'content' 0.00700.0035 776.171994.3125
Module end 'content' 0.01050.0015 870.484433.9922
Script end 0.0120  904.4766 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002419.9801140.0002
Check MTime0.00118.8719140.0001
Mysql Total
Database connection0.00086.599710.0008
Mysqli_queries0.002016.366930.0007
Looping result0.00000.091510.0000
Template Total0.00119.510.0011
Template load0.00108.119810.0010
Template processing0.00021.343010.0002
Override
Cache load0.00075.624810.0007
General
dbfile0.00021.750980.0000
String conversion0.00000.047840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs