Take the 2-minute tour ×

I've found an issue with array types at doctrine2.

In my app I've some users with come frome slovenia. These guys have some strange chars like "čćšž". After this value gets serialized and stored into the database the issue occurs.

After that I get following expection: Notice: unserialize() [function.unserialize]: Error at offset 456 of 645 bytes in /Applications/MAMP/htdocs/firegames.at/vendor/doctrine-dbal/lib/Doctrine/DBAL/Types/ArrayType.php line 46

So I figured out that the following content in the serialized sting triggers the expection: s:7:"Urani?"

But It should be Uranić. I tryied to convert the string into utf8 but it also fails. The chars cant't be encoded!

It's interresting if I replace the ? directly with the ć it works as expected. Also strange is that the char ž makes no issue. That's the only one which works.

So anyone an idea how to fix that?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

What you need to do is tell DBAL to do "SET NAMES utf8" when connecting to the DB. This is done by passing the charset='utf8' parameter to the config. You might want to read the documentation, where you'll find that this is only possible with PDO MySQL and OCI (Oracle) but I assume you are using MySQL.

Additionally, did you create your table cells using CHARACTER SET utf8 COLLATE utf8_slovenian_ci?

share|improve this answer
thx, for your response it's working now –  sensi Nov 19 '12 at 17:52
add comment

Your Answer


