Contao 4 with auto parameters:
PHP Code:
<?php
$parameters = file('../app/config/parameters.yml');
$params = array();
foreach($parameters as $value)
{
if(strpos($value, ': ') === false)
{
continue;
}
$param = explode(': ', trim($value));
$params[$param[0]] = $param[1];
}
// Database credentials
$strHost = $params['database_host'].':'.$params['database_port'];
$strUser = $params['database_user'];
$strPassword = $params['database_password'];
$strDatabase = $params['database_name'];
// Main Script
$con = mysqli_connect( $strHost, $strUser, $strPassword, $strDatabase);
if (mysqli_connect_errno()) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging error : " . mysqli_connect_errno() . PHP_EOL;
exit;
}
$result = $con->query('show tables');
while($tables = mysqli_fetch_array($result)) {
#$con->query("ALTER TABLE $tables[0] CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");
$con->query("ALTER TABLE $tables[0] CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci");
}
echo "The collation of your database has been successfully changed!";
Set the default collation of your database to utf8[mb4]_unicode_c manually.
If you have problems with utf8mb4_unicode_ci use utf8_unicode_ci instead.
Bookmarks