Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Issue 4662 - Zend\Db\PDO adapter driver ignores charset option #4973

Merged
merged 1 commit into from

3 participants

@dlu-gs

No description provided.

@Ocramius
Collaborator

@dlu-gs missing test

@dlu-gs

I haven't found any tests in ZendTest\Db\Adapter\Driver\Pdo\ConnectionTest which would test the connection paramaters (there is only a single test method testing exception thrown upon connection attempt without any params). Where are the original tests for this class which test the other connection parameters?

@Ocramius
Collaborator

@dlu-gs ah, I see... tricky one. I was assuming the $dsn was accessible somewhere.

@dlu-gs

Exactly. I'd have to write a PDO mock to test the DSN has been assembled correctly with the charset option.
Since there were no similar tests present I followed suit and skipped mine too :)

@akrabat akrabat referenced this pull request from a commit
@akrabat akrabat Merge branch 'hotfix/4662-pdo-adapter-ignoring-charset' of github.com…
…:dlu-gs/zf2 into pr4973

Closes #4973
b90d835
@akrabat akrabat merged commit 7a3f4a4 into zendframework:develop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 0 deletions.
  1. +6 −0 library/Zend/Db/Adapter/Driver/Pdo/Connection.php
View
6 library/Zend/Db/Adapter/Driver/Pdo/Connection.php
@@ -240,6 +240,9 @@ public function connect()
case 'dbname':
$database = (string) $value;
break;
+ case 'charset':
+ $charset = (string) $value;
+ break;
case 'driver_options':
case 'options':
$value = (array) $value;
@@ -267,6 +270,9 @@ public function connect()
if (isset($port)) {
$dsn[] = "port={$port}";
}
+ if (isset($charset)) {
+ $dsn[] = "charset={$charset}";
+ }
break;
}
$dsn = $pdoDriver . ':' . implode(';', $dsn);
Something went wrong with that request. Please try again.