Issues

ZF2-280: PDO options problem

Issue Type: Bug Created: 2012-04-27T10:34:05.000+0000 Last Updated: 2012-05-10T14:38:19.000+0000 Status: Resolved Fix version(s): Reporter: Dip Woodle (dipwoodle) Assignee: Ralph Schindler (ralph) Tags: - Zend\Db

Related issues: Attachments:

Description

In DI parameters:

<pre class="highlight"> 
...
'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()
<pre class="highlight"> 
case 'driver_options':
case 'options':
    $options = array_merge($options, (array) $value);
break;

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

<pre class="highlight">
$value = array(1002 => 'SET NAMES \'UTF8\'')

and after merging:

<pre class="highlight">
$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

Posted by Dip Woodle (dipwoodle) on 2012-05-10T14:38:19.000+0000

http://framework.zend.com/issues/browse/ZF2-188

Solved earlier. Sorry.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts