From ab57a0105d107fd08936bff173345ff8aeb006e5 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Thu, 5 Jul 2012 23:00:50 +0200 Subject: [PATCH] [DBAL-243] Remove Connection#setCharset() --- UPGRADE | 15 +++++++++++++++ lib/Doctrine/DBAL/Connection.php | 10 ---------- lib/Doctrine/DBAL/Platforms/AbstractPlatform.php | 14 -------------- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/UPGRADE b/UPGRADE index 585f1689866..67a635d13fc 100644 --- a/UPGRADE +++ b/UPGRADE @@ -1,5 +1,20 @@ # Upgrade to 2.3 +## Doctrine\DBAL\Connection#setCharsetSQL() removed + +This method only worked on MySQL and it is considered unsafe on MySQL to use SET NAMES UTF-8 instead +of setting the charset directly on connection already. Replace this behavior with the +connection charset option: + +Before: + + $conn = DriverManager::getConnection(array(..)); + $conn->setCharset('UTF8'); + +After: + + $conn = DriverManager::getConnection(array('charset' => 'UTF8', ..)); + ## Doctrine\DBAL\Schema\Table#renameColumn() removed Doctrine\DBAL\Schema\Table#renameColumn() was removed, because it drops and recreates diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index a4e6f2263c6..067b3f7bdbe 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -539,16 +539,6 @@ public function insert($tableName, array $data, array $types = array()) return $this->executeUpdate($query, array_values($data), $types); } - /** - * Sets the given charset on the current connection. - * - * @param string $charset The charset to set. - */ - public function setCharset($charset) - { - $this->executeUpdate($this->_platform->getSetCharsetSQL($charset)); - } - /** * Quote a string so it can be safely used as a table or column name, even if * it is a reserved name. diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index f8864ae11be..0cf0c14a4d7 100644 --- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -2092,20 +2092,6 @@ public function convertBooleans($item) return $item; } - /** - * Gets the SQL statement specific for the platform to set the charset. - * - * This function is MySQL specific and required by - * {@see \Doctrine\DBAL\Connection::setCharset($charset)} - * - * @param string $charset - * @return string - */ - public function getSetCharsetSQL($charset) - { - return "SET NAMES '".$charset."'"; - } - /** * Gets the SQL specific for the platform to get the current date. *