4

I have a project in Phalcon PHP and MySql.

when UTF8 characters have to keep these errors are stored.

For example: I save : nueva descripción ñññ in Database: nueva descipción ñññ

I have tried several types of collations both in the database, tables and fields.

Thanks for your help.

Andrés Luque
  • 71
  • 1
  • 1
  • 3

2 Answers2

5

While having properly defined database elements, you have to also set your connection to use UTF-8 ecoding. As of Phalcon makes use of PDO, you can try to modify your connection alike to:

$di["db"] = function() {
    return new \Phalcon\Db\Adapter\Pdo\Mysql(array(
        "host" => "localhost",
        "username" => "root",
        "password" => "1234",
        "dbname" => "test",
        "options" => array( // this is your important part
            PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
        )
    ));
};

Example from Phalcon Forum.

As of I'm working with Polish language, my DB collations are mostly set to utf8_polish_ci or sometimes to utf8_universal_ci. You have to test it out because of result sorting issues.

yergo
  • 4,761
  • 2
  • 19
  • 41
0

check your project database if it is utf8-unicode-ci collation. Also check all your individual table has collation utf-8-unicode-ci

If it is not ok ,check your apache mysql config my.ini file

In that check UTF 8 Settings has no hash (#) comment like this

## UTF 8 Settings
init-connect=\'SET NAMES utf8\'      //remove #
collation_server=utf8_unicode_ci         
character_set_server=utf8
Jack jdeoel
  • 4,554
  • 5
  • 26
  • 52