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: davidm at Mar 12, 2008, 04:09 AM

    Forgive me to ask such a stupid question, but I think the installer should be very precise : currently, it says "Connection character set:" but in phpMyAdmin there are two things "MySQL charset" and "MySQL connection collation" and they can be different (in my case, MySQL charset is utf8 and default collation is utf8_unicode_ci but all my MODx installs use latin_swedish_ci as collation huh => I am a bit lost as to why it is so...).

    Easy to get confused since the label we apply is a combination of both ("connection" + "charset").
    If I understand correctly MODx looks up the DB collation to determine which charset is used... in my case it won’t work since one is utf8 and the DB’s collation is (somehow) different from the default collation for my server...

    Do I make sense ?
    The database charset should always match the first part of the database collation (up to the first underscore); collation is just a subset of charset. But connection charset is all we are concerned with.

    And don’t get confused by the values in phpmyadmin. Those are that PHP application’s settings and can be set independent of server collation, database collation, table collation, and/or field collation. Aren’t charsets/collations fun? rolleyes

    The problem here folks is we need a list of valid collations for the database server being connected to, so this needs to happen after a successful connection is made. Then we can present a proper dropdown of valid values on the next page (or maybe as a dynamically activated control on the main page). Otherwise, an invalid collation (one not available on the server configuration) will cause the server to error when we issue the SET CHARSET command.
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: coroico at Mar 12, 2008, 09:49 AM

      I got the source code from SVN, but once my tests will be finished, how could i deliver the new version of these files ? and how can I get the translation for the other languages (for French and Spanish it’s ok) ?
      This needs a JIRA ticket first of all. Then you attach a patch (a unified diff created by running svn diff on your local working copy containing your changes). You can also create a code review and attach the patch so the team can review the code using Crucible; this way we can review the changes in the context of the code online as a team before we commit anything. I’d love to see that happen here as a test of this.

      See http://confluence.atlassian.com/display/CRUCIBLE/2.1.7+Creating+a+Patch+Review
        • 5811
        • 1,717 Posts
        Then we can present a proper dropdown of valid values on the next page (or maybe as a dynamically activated control on the main page). Otherwise, an invalid collation (one not available on the server configuration) will cause the server to error when we issue the SET CHARSET command.

        If I take the option to display a dropdown list for the available collations, this new page will have only this drop down. A new page for only one dropdow seems rich ?
        What do you mean by
        maybe as a dynamically activated control on the main page ?
        I will be interested to find and implement a solution
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: coroico at Mar 12, 2008, 10:44 AM

          If I take the option to display a dropdown list for the available collations, this new page will have only this drop down. A new page for only one dropdow seems rich ?
          Agreed...

          Quote from: coroico at Mar 12, 2008, 10:44 AM

          What do you mean by
          maybe as a dynamically activated control on the main page ?
          I will be interested to find and implement a solution
          I meant once the database settings are entered, activating a type-ahead control that populates the drop down from collations returned by an Ajax request. The challenge is safely getting the db settings to the Ajax request I would guess.
            • 7231
            • 4,205 Posts
            The SHOW CHARACTER SET query will return a list of available collation on the db, so maybe perform this after selecting the db connection info to build a menu with these options.
              [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]
              • 7231
              • 4,205 Posts
              This little action/query returns the available collations/charsets during the DB Test. This can be worked into a nice little interface with a list of the collation/charsets to make it easy to select and make sure spelling etc. is correct.

                  // get collation / charset
                  $getCharCol = mysql_query("SHOW CHARACTER SET");
                  if (mysql_num_rows($getCharCol) > 0) {
                  	//$charSelect .= "Available Charset/Collation settings<br />";
                  	$charSelect = "<select id=\"database_collation\" name=\"database_collation\">";
                  	while ($row = mysql_fetch_row($getCharCol)) {
                  		$charSelect .= "<option value=\"".$row[2]."\">".$row[2]."</option>";
                  	}
                  	$charSelect .= "</select>";
                  }


              For this to work the Test DB would need to be a required action and should be renamed to something like "Test DataBase Connection and Get Collation/Charset" or break this down into steps...1) define db info; 2) select collation; 3) define admin user...or something like that.

              Attached is a tweaked example just to show the returned values select test db connection.

              It returns these value pairs on my server:
              big5 | big5_chinese_ci
              dec8 | dec8_swedish_ci
              cp850 | cp850_general_ci
              hp8 | hp8_english_ci
              koi8r | koi8r_general_ci
              latin1 | latin1_swedish_ci
              latin2 | latin2_general_ci
              swe7 | swe7_swedish_ci
              ascii | ascii_general_ci
              ujis | ujis_japanese_ci
              sjis | sjis_japanese_ci
              hebrew | hebrew_general_ci
              tis620 | tis620_thai_ci
              euckr | euckr_korean_ci
              koi8u | koi8u_general_ci
              gb2312 | gb2312_chinese_ci
              greek | greek_general_ci
              cp1250 | cp1250_general_ci
              gbk | gbk_chinese_ci
              latin5 | latin5_turkish_ci
              armscii8 | armscii8_general_ci
              utf8 | utf8_general_ci
              ucs2 | ucs2_general_ci
              cp866 | cp866_general_ci
              keybcs2 | keybcs2_general_ci
              macce | macce_general_ci
              macroman | macroman_general_ci
              cp852 | cp852_general_ci
              latin7 | latin7_general_ci
              cp1251 | cp1251_general_ci
              cp1256 | cp1256_general_ci
              cp1257 | cp1257_general_ci
              binary | binary
              geostd8 | geostd8_general_ci
              cp932 | cp932_japanese_ci
              eucjpms | eucjpms_japanese_ci
                [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&#39;t know what it is.
                Do you, Mr. Jones? - [bob dylan]
                • 22303 MODX Staff
                • 10,725 Posts
                Does this work, even if the database does not yet exist, and thus the connection test fails?
                  • 5811
                  • 1,717 Posts
                  An another option is to use "SHOW COLLATION". It gives the same results than SHOW CHARACTER SET

                  Ok, as suggested by Shane, now we should replace the test connection button test by a "test your connection and get the collation" button.

                  The user test his database connection, a message "Connection to host: passed... Checking database: passed" is displayed (or not). If the DB connection is OK a list of available collation is displayed. The user choose the collation and then continue to the admin user part.

                  And before to move to the next page, we need to check that the collation input is not empty. If empty, we ask to the user to test his connection and set his collation.
                  In French after that we say "y a plus qu’à". (ya+k in abreviated language). In english, not sure but "it’s time to move on" seems a correct translation too wink I will try to work on that tomorrow.
                    • 7231
                    • 4,205 Posts
                    Quote from: OpenGeek at Mar 12, 2008, 03:49 PM

                    Does this work, even if the database does not yet exist, and thus the connection test fails?
                    Not sure, I think all it needs to do is connect to the db server and not a specific database, therefore if you can connect then you can get the results...not 100% sure though, will do some testing. I think corioco is moving ahead with this and may be much better qualified to fine tune it wink
                      [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&#39;t know what it is.
                      Do you, Mr. Jones? - [bob dylan]
                      • 22303 MODX Staff
                      • 10,725 Posts
                      Quote from: coroico at Mar 12, 2008, 05:24 PM

                      The user test his database connection, a message "Connection to host: passed... Checking database: passed" is displayed (or not). If the DB connection is OK a list of available collation is displayed. The user choose the collation and then continue to the admin user part.
                      If the database does not exist, we create the database during install, so make sure this works when you don’t have a valid database connection, or we’ll have to change the test db connection to be a test db connection and/or create db. But of course, you can’t create the db until you know what collation/charset they have selected. Grrrrr....