Skip to content

Commit

Permalink
Adding version check to getCharsetName() for MySQL Datasource.
Browse files Browse the repository at this point in the history
  • Loading branch information
predominant committed Nov 16, 2009
1 parent aa97dae commit a91108a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cake/libs/model/datasources/dbo/dbo_mysql.php
Expand Up @@ -456,13 +456,14 @@ function listDetailedSources($name = null) {
* @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;
}

}

/**
Expand Down

0 comments on commit a91108a

Please sign in to comment.