spotorm / spot2

Spot v2.x DataMapper built on top of Doctrine's Database Abstraction Layer
http://phpdatamapper.com
BSD 3-Clause "New" or "Revised" License
601 stars 101 forks source link

Encoding problem #263

Closed mvnaz closed 5 years ago

mvnaz commented 6 years ago

Hello, I use that library. I have problem with encoding.

It doesn't show russian characters correctly, and also chars like that " Frühlingsausläufer überall "

I tried:

'charset' => 'utf8mb4'

FlipEverything commented 6 years ago

I don't think that this is Spot related. You can set charset like this: #227 Maybe you have to set the charset on the client side too. You may check the database structure as well.

If you need further assistance, please be more specific and post the related code.

dertin commented 6 years ago

Maybe someone can add these two methods to the configuration class. How do they see it?

  $cfg = new \Spot\Config();

  $cfg->addConnection(DB_TYPE_CONFIG, [
            'dbname' => DB_NAME_CONFIG,
            'user' => DB_USER_CONFIG,
            'password' => DB_PASS_CONFIG,
            'host' => DB_HOST_CONFIG,
            'driver' => DB_DRIVER_CONFIG,
   ]);

   $cfg->setCharset('utf8');

   // SQL: "SET collation_connection = utf8_spanish_ci"
   $cfg->setCollation('utf8_spanish_ci');
vlucas commented 5 years ago

These issues are mostly MySQL-specific, which is why the commands are not in the API. I recommend just doing a query first, or altering your tables to specify it in the schema.

FlipEverything commented 5 years ago

Feel free to reopen this issue If you need further assistance!