FOF30\Database\Installer::convertTablesToUtf8mb4 PHP Method

convertTablesToUtf8mb4() private method

Converts the collation of tables listed in $tablesToConvert to utf8mb4_unicode_ci
private convertTablesToUtf8mb4 ( array $tablesToConvert ) : void
$tablesToConvert array The list of tables to convert
return void
    private function convertTablesToUtf8mb4($tablesToConvert)
    {
        // Make sure the database driver REALLY has support for converting character sets
        if (!method_exists($this->db, 'getAlterTableCharacterSet')) {
            return;
        }
        asort($tablesToConvert);
        foreach ($tablesToConvert as $tableName) {
            $collation = $this->getTableCollation($tableName);
            $parts = explode('_', $collation, 3);
            $encoding = empty($parts[0]) ? '' : strtolower($parts[0]);
            if ($encoding != 'utf8mb4') {
                $queries = $this->db->getAlterTableCharacterSet($tableName);
                try {
                    foreach ($queries as $query) {
                        $this->db->setQuery($query)->execute();
                    }
                } catch (\Exception $e) {
                    // We ignore failed conversions. Remember, you MUST change your indices MANUALLY.
                }
            }
        }
    }