ZF2-280: PDO options problem

Description

In DI parameters:

 
...
'driver' => array(
    'driver'         => 'Pdo',
    'dsn'            => 'mysql:dbname=zftest;host=localhost',
    'username'       => 'root',
    'password'       => '',
    'driver_options' => array(
        PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
    ),
)
...

Option 'driver_options' doesn't work, because:

  1. PDO::MYSQL_ATTR_INIT_COMMAND => 1002
  2. Zend\Db\Adapter\Driver\Pdo\Connection::connect()
 
case 'driver_options':
case 'options':
    $options = array_merge($options, (array) $value);
break;

After array_merge() numeric keys will be renumbered! In out case


$value = array(1002 => 'SET NAMES \'UTF8\'')

and after merging:


$options = array(0 => 'SET NAMES \'UTF8\'')

. Error! PDO constructor in options parameter expect constants values, ex. PDO::MYSQL_ATTR_*.

PS: Sorry for my english.

Comments