From a91108a81af2a613b53f63eaa6120e36d8bf81b2 Mon Sep 17 00:00:00 2001 From: predominant Date: Mon, 16 Nov 2009 13:49:52 +1100 Subject: [PATCH] Adding version check to getCharsetName() for MySQL Datasource. --- cake/libs/model/datasources/dbo/dbo_mysql.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index f4b77f0a3..d2ad87118 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -456,13 +456,14 @@ class DboMysqlBase extends DboSource { * @return string Character set name */ function getCharsetName($name) { - $cols = $this->query('SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLLATIONS WHERE COLLATION_NAME= ' . $this->value($name) . ';'); - if (isset($cols[0]['COLLATIONS']['CHARACTER_SET_NAME'])) { - return $cols[0]['COLLATIONS']['CHARACTER_SET_NAME']; + if ((bool)version_compare(mysql_get_server_info($this->connection), "5", ">=")) { + $cols = $this->query('SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLLATIONS WHERE COLLATION_NAME= ' . $this->value($name) . ';'); + if (isset($cols[0]['COLLATIONS']['CHARACTER_SET_NAME'])) { + return $cols[0]['COLLATIONS']['CHARACTER_SET_NAME']; + } } return false; } - } /**