You are here

function persiantools_sort_fix_submit in PersianTools 8

Same name and namespace in other branches
  1. 7 persiantools.admin.inc \persiantools_sort_fix_submit()
1 string reference to 'persiantools_sort_fix_submit'
PersianToolsAdminForm::buildForm in src/Form/PersianToolsAdminForm.php
Form constructor.

File

./persiantools.module, line 47

Code

function persiantools_sort_fix_submit() {
  $dbinfo = Database::getConnectionInfo('default');
  $dbname = $dbinfo['default']['database'];
  db_query('ALTER DATABASE ' . $dbname . ' DEFAULT CHARACTER SET utf8 COLLATE utf8_persian_ci');
  $table_ref = "Tables_in_{$dbname}";
  $result = db_query("SHOW TABLES");
  foreach ($result as $tableinfo) {
    $tablename = $tableinfo->{$table_ref};
    db_query('ALTER TABLE ' . $tablename . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_persian_ci');
  }
  drupal_set_message(t('Default database collation, and collation for all tables changed to persian (utf8_persian_ci).'), 'status', FALSE);
}