Home Ask Login Register

Developers Planet

Your answer is one click away!

Matthieu February 2016

Doctrine 1.2 query with utf8 column name

I have this same problem, but with Doctrine 1.2 instead of Doctrine 2.0.

I have a column with non-Ascii character in his name, and Doctrine give me this error when I try to select it :

Message: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '??_avanc?? AS c4__1 (...)

Where there should be the french "é" char instead of the double questions marks.

Here is my connection :

$conn = Doctrine_Manager::connection("mysql://username:password@locahost/mydb","my_connection");

And here is my select :

$q = Doctrine_Query::create()->select("vicl_relevé_avancé vc")->FROM("vc.VisiteClient")->where("vc.id = ?", $id)->execute();

Thanks for your help


Rick James February 2016

Double question marks? Ouch. That probably implies that multiple things are going wrong.

The table/column needs to be CHARACTER SET utf8; see SHOW CREATE TABLE to check on that. Fixing that may fix the problem, but it may just make it different.

SELECT col, HEX(col) FROM tbl WHERE ... -- to see what is actually stored. latin1 will show E9 for é; utf8 will show C3A9 for é.

Post Status

Asked in February 2016
Viewed 2,377 times
Voted 8
Answered 1 times


Leave an answer

Quote of the day: live life