From: Jan Schneider Date: Tue, 30 Nov 2010 14:41:59 +0000 (+0100) Subject: Remove charset methods. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=fa8d644f8ca59a43056e5eae668ff1699d36be24;p=horde.git Remove charset methods. They are only implemented in the MySQL drivers anyway and using SET NAMES causes more problems than it solves. Actually it breaks the current share driver. --- diff --git a/framework/Db/lib/Horde/Db/Adapter/Base.php b/framework/Db/lib/Horde/Db/Adapter/Base.php index 1348f5ac7..adaec96ad 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Base.php +++ b/framework/Db/lib/Horde/Db/Adapter/Base.php @@ -108,10 +108,7 @@ abstract class Horde_Db_Adapter_Base implements Horde_Db_Adapter /** * Constructor. * - * @param array $config Configuration options and optional objects: - *
-     * 'charset' - (string) TODO
-     * 
+ * @param array $config Configuration options and optional objects. */ public function __construct($config) { @@ -121,11 +118,6 @@ abstract class Horde_Db_Adapter_Base implements Horde_Db_Adapter $this->_cache = new Horde_Support_Stub(); $this->_logger = new Horde_Support_Stub(); - // Default to UTF-8 - if (!isset($config['charset'])) { - $config['charset'] = 'UTF-8'; - } - $this->_config = $config; $this->_runtime = 0; diff --git a/framework/Db/lib/Horde/Db/Adapter/Mysql.php b/framework/Db/lib/Horde/Db/Adapter/Mysql.php index 3f11e42c2..2ad4cccf2 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Mysql.php +++ b/framework/Db/lib/Horde/Db/Adapter/Mysql.php @@ -101,11 +101,6 @@ class Horde_Db_Adapter_Mysql extends Horde_Db_Adapter_Base $this->_connection = $mysql; $this->_active = true; - - // Set the default charset. http://dev.mysql.com/doc/refman/5.1/en/charset-connection.html - if (!empty($config['charset'])) { - $this->setCharset($config['charset']); - } } /** diff --git a/framework/Db/lib/Horde/Db/Adapter/Mysql/Schema.php b/framework/Db/lib/Horde/Db/Adapter/Mysql/Schema.php index 005ce3409..66ab22e25 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Mysql/Schema.php +++ b/framework/Db/lib/Horde/Db/Adapter/Mysql/Schema.php @@ -131,54 +131,6 @@ class Horde_Db_Adapter_Mysql_Schema extends Horde_Db_Adapter_Base_Schema } /** - * Returns the database character set that query results are in - * - * @return string - */ - public function getCharset() - { - return $this->showVariable('character_set_results'); - } - - /** - * Set the client and result charset. - * - * @param string $charset The character set to use for client queries and results. - */ - public function setCharset($charset) - { - $charset = $this->_mysqlCharsetName($charset); - $this->execute('SET NAMES ' . $this->quoteString($charset)); - } - - /** - * Get the MySQL name of a given character set. - * - * @param string $charset - * @return string MySQL-normalized charset. - */ - public function _mysqlCharsetName($charset) - { - $charset = strtolower(preg_replace(array('/[^a-zA-Z0-9]/', '/iso8859(\d)/'), array('', 'latin$1'), $charset)); - $validCharsets = $this->selectValues('SHOW CHARACTER SET'); - if (!in_array($charset, $validCharsets)) { - throw new Horde_Db_Exception($charset . ' is not supported by MySQL'); - } - - return $charset; - } - - /** - * Returns the database collation strategy - * - * @return string - */ - public function getCollation() - { - return $this->showVariable('collation_database'); - } - - /** * List of tables for the db * * @param string $name @@ -271,10 +223,13 @@ class Horde_Db_Adapter_Mysql_Schema extends Horde_Db_Adapter_Base_Schema * @param string $name * @param array $options */ - public function endTable($name, $options=array()) + public function endTable($name, $options = array()) { - $opts = array('options' => 'ENGINE=InnoDB DEFAULT CHARSET=' . $this->getCharset()); - return parent::endTable($name, array_merge($opts, $options)); + $opts = 'ENGINE=InnoDB'; + if (!empty($options['charset'])) { + $opts .=' DEFAULT CHARSET=' . $options['charset']; + } + return parent::endTable($name, array_merge(array('options' => $opts), $options)); } /** diff --git a/framework/Db/lib/Horde/Db/Adapter/Mysqli.php b/framework/Db/lib/Horde/Db/Adapter/Mysqli.php index a8c2f9d5e..185e6c3d8 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Mysqli.php +++ b/framework/Db/lib/Horde/Db/Adapter/Mysqli.php @@ -149,12 +149,6 @@ class Horde_Db_Adapter_Mysqli extends Horde_Db_Adapter_Base $this->_connection = $mysqli; $this->_active = true; - - // Set the default charset. http://dev.mysql.com/doc/refman/5.1/en/charset-connection.html - if (!empty($config['charset'])) { - $this->setCharset($config['charset']); - } - $this->_hasMysqliFetchAll = function_exists('mysqli_fetch_all'); } diff --git a/framework/Db/lib/Horde/Db/Adapter/Pdo/Mysql.php b/framework/Db/lib/Horde/Db/Adapter/Pdo/Mysql.php index 938172db8..250d8ab6c 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Pdo/Mysql.php +++ b/framework/Db/lib/Horde/Db/Adapter/Pdo/Mysql.php @@ -63,11 +63,6 @@ class Horde_Db_Adapter_Pdo_Mysql extends Horde_Db_Adapter_Pdo_Base parent::connect(); // ? $this->_connection->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); - - // Set the default charset. http://dev.mysql.com/doc/refman/5.1/en/charset-connection.html - if (!empty($this->_config['charset'])) { - $this->setCharset($this->_config['charset']); - } } diff --git a/framework/Db/test/Horde/Db/Adapter/MysqlTest.php b/framework/Db/test/Horde/Db/Adapter/MysqlTest.php index 00cb5f42e..082404432 100644 --- a/framework/Db/test/Horde/Db/Adapter/MysqlTest.php +++ b/framework/Db/test/Horde/Db/Adapter/MysqlTest.php @@ -128,11 +128,6 @@ class Horde_Db_Adapter_MysqlTest extends PHPUnit_Framework_TestCase $this->assertTrue($this->_conn->supportsCountDistinct()); } - public function testGetCharset() - { - $this->assertEquals('utf8', strtolower($this->_conn->getCharset())); - } - /*########################################################################## # Database Statements diff --git a/framework/Db/test/Horde/Db/Adapter/MysqliTest.php b/framework/Db/test/Horde/Db/Adapter/MysqliTest.php index fe92d4b1a..6fac38deb 100644 --- a/framework/Db/test/Horde/Db/Adapter/MysqliTest.php +++ b/framework/Db/test/Horde/Db/Adapter/MysqliTest.php @@ -128,11 +128,6 @@ class Horde_Db_Adapter_MysqliTest extends PHPUnit_Framework_TestCase $this->assertTrue($this->_conn->supportsCountDistinct()); } - public function testGetCharset() - { - $this->assertEquals('utf8', strtolower($this->_conn->getCharset())); - } - /*########################################################################## # Database Statements diff --git a/framework/Db/test/Horde/Db/Adapter/Pdo/MysqlTest.php b/framework/Db/test/Horde/Db/Adapter/Pdo/MysqlTest.php index 0a4734424..f0f7b9422 100644 --- a/framework/Db/test/Horde/Db/Adapter/Pdo/MysqlTest.php +++ b/framework/Db/test/Horde/Db/Adapter/Pdo/MysqlTest.php @@ -128,11 +128,6 @@ class Horde_Db_Adapter_Pdo_MysqlTest extends PHPUnit_Framework_TestCase $this->assertTrue($this->_conn->supportsCountDistinct()); } - public function testGetCharset() - { - $this->assertEquals('utf8', strtolower($this->_conn->getCharset())); - } - /*########################################################################## # Database Statements