1

I have installed Propel 1.6. I can create tables in MySQL with propel commands.

Below is my propel settings in file: runtime-config.xml

 <propel>
            <datasources default="myProject">
                <datasource id="myProject">
                    <adapter>mysql</adapter> 
                    <connection>
                        <dsn>mysql:host=localhost;dbname=myDBname</dsn>
                        <user>myUser</user>
                        <password>mypass</password>
                        **<charset>utf8</charset>
                        <collate>utf8_unicode_ci</collate>**

                    </connection>
                </datasource>
            </datasources>
        </propel>

MySQL database and table User has collation utf8_unicode_ci (see photo below):

mySql collation screenshot

Ι create a new Patient object to test everything is ok, through the following code:

$pat = new Patient();
$pat->setEmail("tg@gmail.com");
$pat->setAddress("Η διεύθυνσή μου");
$pat->setAmka("555555555");
$pat->setBirthdate("1966-01-01");
$pat->setFirstname("Τοόνομάμου");
$pat->setLastname("τοεπώνυμόμου");
$pat->setPhone("2109999999");
$pat->setSex(1);

$pat->save();

I checked through debug mode in Netbeans and the object $pat contains the values in the correct format so i can read them.

After save(), in mysql the greek values are showing like this: mySql values saved screenshot

I would like your help to solve this issue. Thank you in advance.

billato
  • 13
  • 4

3 Answers3

0

Τοόνομάμου, when "Mojibaked", becomes Τοόνομάμου. Notice the pattern often has Î and a second character, like your screenshot. Apparently, latin1 was involved at some point.

Trouble with UTF-8 characters; what I see is not what I stored discusses Mojibake and its causes.

It may be that you have "double encoding", which that link also discusses.

If you choose to fix the data rather than start over, see http://mysql.rjweb.org/doc.php/charcoll#fixes_for_various_cases

Rick James
  • 135,179
  • 13
  • 127
  • 222
0

Finally, i found a solution.

In MySQL, i checked my settings using the following command:

show variables like 'char%';

I had to replace character_set utf8 with utf8mb4.

Everything works perfect now!!

For more info, https://mathiasbynens.be/notes/mysql-utf8mb4

billato
  • 13
  • 4
0

You must specify the charset in the propel connection DSN - in your runtime-config.xml file like this:

<dsn>mysql:host=localhost;dbname=myDBname;charset=UTF8</dsn>

https://github.com/propelorm/sfPropelORMPlugin/issues/74#issuecomment-2011350

Alex P.
  • 1,140
  • 13
  • 27