1 charset_converter.inc public DatabaseCharsetConverter::convertDatabase($database_name, $charset = NULL, $collation = NULL)

Convert the database charset and collation, but not the tables within it.

Parameters

string $database_name: Database name.

string|null $charset: (Optional) The character set. Defaults to the constructor value.

string|null $collation: (Optional) The collation. Defaults to the constructor value.

Return value

bool: TRUE if the database is converted successfully, FALSE on failure.

Throws

PDOException

File

core/includes/database/charset_converter.inc, line 135

Class

DatabaseCharsetConverter
Character set converter for database tables.

Code

public function convertDatabase($database_name, $charset = NULL, $collation = NULL) {
  $sql = "ALTER DATABASE `$database_name` CHARACTER SET = :charset COLLATE = :collation;";
  return $this->connection->query($sql, array(
    ':charset' => $charset ? : $this->charset,
    ':collation' => $collation ? : $this->collation,
  ));
}