We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22303 MODX Staff
    • 10,725 Posts
    Quote from: BobRay at Feb 20, 2008, 01:21 PM

    The more I mess with this, the more I wonder if we shouldn’t advise people check their server settings and their database permissions before making a decision.

    I’ve found that on one old site of mine, I can only create a databse using their cPanel wizard, which doesn’t allow you to set any charsert stuff. Every db I create there will end up with latin1 and latin1_swedish_ci for the database setting, although I can set *tables* to have anything I want. In a case like that, wouldn’t it make more sense to do everything in latin1 unless there was some compelling reason for using UTF-8?
    I think an informational page before setting up the database would indeed be a great idea. BTW, in this cPanel situation, do you have rights to ALTER DATABASE? cPanel is very common and it might be worth mentioning in the page how to deal with it.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      After you create the database in CPanel, you can go to phpMyAdmin and change the collation of the empty database to utf8_general_ci or whatever. That will set the charset of the database to utf8, and all tables will have the utf8_general_ci collation.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 7231
        • 4,205 Posts
        The more I mess with this, the more I wonder if we shouldn’t advise people check their server settings and their database permissions before making a decision.
        Ironically I just checked my server (cPanel) and all of the MODx databases (there are 5) are all correctly set to UTF8 grin All the other stuff I have messed with or installed is all latin1. I am on a VPS so I may have more privileges than shared hosting users. The catch is you do not set the collation on creation in cpanel, you need to alter the db after creating it and before installing MODx.

        I cut my teeth with mysql pre 4.1 so the concern about collation is a new or recent one for me. But I humbly think that anyone who is going to work with this stuff professionally needs to have some understanding of this before hand. I only can blame myself for my errors in having assumed that it was not an issue. I think this is a a trend throughout the web as things get more specific and I get older shocked

        If I recall correctly modx identifies the collation of the database before hand and pre-fills the field accordingly, here is the code that does that:
        // check the database collation if not specified in the configuration
        if ($upgradeable && (!isset ($database_connection_charset) || empty($database_connection_charset))) {
            if (!$rs = @ mysql_query("show session variables like 'collation_database'")) {
                $rs = @ mysql_query("show session variables like 'collation_server'");
            }
            if ($rs && $collation = mysql_fetch_row($rs)) {
                $database_collation = $collation[1];
            }
            if (empty ($database_collation)) {
                $database_collation = 'utf8_general_ci';
            }
            $database_charset = substr($database_collation, 0, strpos($database_collation, '_'));
            $database_connection_charset = $database_charset;
        } else {
            $database_collation = 'utf8_general_ci';
        }


        This is basically telling you that the server setting is xx and if it can’t get a value it defaults to utf8.

        I think an informational page before setting up the database would indeed be a great idea. BTW, in this cPanel situation, do you have rights to ALTER DATABASE? cPanel is very common and it might be worth mentioning in the page how to deal with it.
        Time to feed the wiki...it’s been hungry. BUt I heard that it is craving some video casts grin

        BTW - anyone seen the cool install videocast for installing Duppy 6, something like this could really help newcommers:
        http://ftp.drupal.org/files/videocasts/Install-D6.mp4

        To bad I sound like an idiot, need to have a good voice to do a cast grin
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don't know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 3749
          • 24,544 Posts
          @dev_cq,

          You’re right. I realized that I *can* set the collation after creating the DB but before creating tables on the "Operations" tab of PhpMyAdmin at any of my sites.

          That would be good advice to have in the Wiki.

          Bob
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting