FOF30\Database\Installer::convertUtf8QueryToUtf8mb4 PHP Method

convertUtf8QueryToUtf8mb4() private method

Automatically upgrade a CREATE TABLE or ALTER TABLE query from plain utf8 to utf8mb4 (UTF-8 Multibyte).
private convertUtf8QueryToUtf8mb4 ( string $query ) : string
$query string The query to convert
return string The converted query
    private function convertUtf8QueryToUtf8mb4($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 utf8 with utf8mb4
        $from = array('utf8_general_ci', 'utf8_', 'utf8');
        $to = array('utf8mb4_unicode_ci', 'utf8mb4_', 'utf8mb4');
        return str_replace($from, $to, $query);
    }