Skip to content

Commit

Permalink
Merge pull request #152 from fzaninotto/fix_charset_parsing
Browse files Browse the repository at this point in the history
Fix parsing of charset by PDO at runtime
  • Loading branch information
willdurand committed Mar 16, 2012
2 parents bbb1681 + 5995aa4 commit 13c4e82
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function bindValue(StatementInterface $stmt, $parameter, $value, ColumnMa
*/
protected function prepareParams($params)
{
if (isset($params['settings']['charset']['value'])) {
if (isset($params['settings']['charset'])) {
if (version_compare(PHP_VERSION, '5.3.6', '<')) {
throw new PropelException(<<<EXCEPTION
Connection option "charset" cannot be used for MySQL connections in PHP versions older than 5.3.6.
Expand All @@ -206,7 +206,7 @@ protected function prepareParams($params)
);
} else {
if (false === strpos($params['dsn'], ';charset=')) {
$params['dsn'] .= ';charset=' . $params['settings']['charset']['value'];
$params['dsn'] .= ';charset=' . $params['settings']['charset'];
unset($params['settings']['charset']);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ protected function prepareParams($conparams)
*/
public function initConnection(ConnectionInterface $con, array $settings)
{
if (isset($settings['charset']['value'])) {
$this->setCharset($con, $settings['charset']['value']);
if (isset($settings['charset'])) {
$this->setCharset($con, $settings['charset']);
}

if (isset($settings['queries']) && is_array($settings['queries'])) {
Expand Down
4 changes: 1 addition & 3 deletions tests/Propel/Tests/Runtime/Adapter/Pdo/MysqlAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ static public function getConParams()
array(
'dsn' => 'dsn=my_dsn',
'settings' => array(
'charset' => array(
'value' => 'foobar'
)
'charset' => 'foobar'
)
)
)
Expand Down

0 comments on commit 13c4e82

Please sign in to comment.