private function convertUtf8mb4QueryToUtf8($query)
{
// If it's not an ALTER TABLE or CREATE TABLE command there's nothing to convert
$beginningOfQuery = substr($query, 0, 12);
$beginningOfQuery = strtoupper($beginningOfQuery);
if (!in_array($beginningOfQuery, array('ALTER TABLE ', 'CREATE TABLE'))) {
return $query;
}
// Replace utf8mb4 with utf8
$from = array('utf8mb4_unicode_ci', 'utf8mb4_', 'utf8mb4');
$to = array('utf8_general_ci', 'utf8_', 'utf8');
return str_replace($from, $to, $query);
}