We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

DB config & Ini file

I just want to make sure I understood correctly.

Ini config like:

[database]

adapter      = Mysql
options.1002 = SET NAMES 'UTF8'
options.8    = 2

Is equivalent for:

'database' => [
    'adapter'      => 'Mysql',
    'options'      => [
        PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'",
        PDO::ATTR_CASE => PDO::CASE_LOWER
    ],
]

Right?



34.6k
Accepted
answer

Yes, it's equivalent

edited Nov '15

Where did you get the ID's of an 'options' array?

1002 = set names.... etc.

This is my var dump of config service (just 'options' key with values):

[options] => Phalcon\Config Object ( [1002] => SET NAMES GREEK [12] => 1 [20] => 0 [3] => 2 [8] => 2 )

The above actually is a result from config.php which maps to:

PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES GREEK', PDO::ATTR_PERSISTENT => 1, PDO::ATTR_EMULATE_PREPARES => 0, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_CASE => PDO::CASE_LOWER

And somewhat it doesn't work. Even though I set wrong names ('Greek'), I'm still getting the correct result from the database (which is UTF8 btw, tables are utf8_general_ci).

If I try that directly on the command line or other app like Adminer the behaviour is correct (i.e. with all the specific chars = ???????????)