Setting up additional PDO options doesn't seem to work

In config I have the following array of options:

    'port' => 13306,
        'charset' => 'utf8',
        'options' => [ 
            PDO::ATTR_PERSISTENT => 1,
            PDO::ATTR_EMULATE_PREPARES => 0,

But the result set is still utf8, most probabbly since 'charset' = 'utf8'.

If I issue same command just before the SELECT query like:

!$db->execute('SET NAMES GREEK') && exit('SET NAMES FAILURE. STOP RUN.');

Then it works. The result set is encoded propertly.

I wonder what's the use of global PDO options if it doesn't work? Or am I missing something.


Phalcon\Config Object
    [12] => 1
    [1002] => SET NAMES GREEK
    [20] => 0
    [3] => 2
edited Nov '15

OK, rubber duck programming.

If this variable is set in initial config:

'charset' => 'utf8'

Then the framework just doesn't respect PDO::MYSQL_ATTR_INIT_COMMAND at all! Even though it should. Just doesn't care about it, it expects only 'charset' to be set.

Instead of proper formatting I get garbage:

[name] => ?????? ????

Does it matter the DB, I'm using latest stable MariaDB, not MySQL by $oracle.

Soooo if you want greek collation, why use charset=utf8 at all?

It should work by omitting charset and using only MYSQL_ATTR_INIT_COMMAND

Yes, that's the point of my previous post. If you ommit charset - you'll be able to set desired charset using raw MYSQL_ATTR_INIT_COMMAND.

So, in general, 'charset' => 'utf8' is enough for most languages out of the box.