We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12844
    • 59 Posts
    As requested here, I’m posting this here. smiley

    [!Ditto? &parents=`6` &depth=`1` &tpl=`testimonial` &orderBy=`menuindex` &sortDir=`ASC` !]

    I’m getting a MySQL error, and my server is running 5.0.67-community.

    If I remove the orderBy parameter it works okay, and I end up with the result I want (results in order of creation, ascending). But I’d like to know why this is happening and if there’s anything I can do to stop it as I may need to customise the order in the future.

    « MODx Parse Error »
    
    MODx encountered the following error while attempting to parse the requested resource:
    
    « Execution of a query to the database failed - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'menuindex' at line 4 »
    
    SQL: SELECT DISTINCT sc.pagetitle,sc.description,sc.content,sc.published,sc.id FROM `abacus_modx`.`modx_site_content` sc LEFT JOIN `abacus_modx`.`modx_document_groups` dg on dg.document = sc.id WHERE sc.id IN (19,20,21,22,23,24,25,26,27,28,29,30,31,32) AND sc.published=1 AND sc.deleted=0 AND (sc.privateweb=0) GROUP BY sc.id ORDER BY sc.createdon ASC, sc.id menuindex


    To me, it looks like the query really is at fault (why are two other fields in ORDER BY at the end?) - could this be a bug in Ditto? I have MODx 0.9.6.3 and Ditto 2.1+.

    Thanks.
      • 3749
      • 24,544 Posts
      Are you absolutely sure about the MySQL version?  Your symptoms fit a bug in MySQL 5.0.51 exactly (if removing "ORDER BY" fixes it, that pretty much clinches the deal). It’s almost certainly fixed in 5.0.67.
        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
        • 12844
        • 59 Posts
        Yes, the thread I originally posted in covered that, which I found by searching.

        I checked the MySQL version in cPanel and phpMyAdmin. Unless my web host has some strange version reporting issue (not likely?) it’s definitely 5.0.67-community.

        Edit:

        I just came across someone else doing some ordering as follows:

        &orderBy=`menuindex ASC`

        This works. smiley

        Were my previous parameters incorrect?

        &orderBy=`menuindex` &sortDir=`ASC`
          • 16183
          • 1,390 Posts
          I think I read somewhere about different MySQL versions reported depending on whether you check in phpMyAdmin or using phpinfo (can’t remember the exact details but something to do with client version versus server version)...anyway, what does phpinfo report (or that is what you checked in cPanel?). You can check phpinfo in modx manager
          /k
            • 12844
            • 59 Posts
            Just edited my previous post when you were replying. smiley
              • 16183
              • 1,390 Posts
              OK...glad you sorted it..but am curious what phpinfo has reported wink

              cheers/k
                • 16278
                • 928 Posts
                Were my previous parameters incorrect?
                Yes. &orderBy is the Ditto 2.1 parameter for ordering the output list, and always expects to have both the field to sort on and the direction, separated by a space. It replaces both &sortBy and &sortDir, and expands your opportunities compared with earlier versions by allowing sorts within sorts.
                cool KP
                See http://www.pogwatch.com/ditto/ditto-sort.html for some live examples.
                  • 12844
                  • 59 Posts
                  Quote from: kongondo at Jun 05, 2009, 05:48 PM

                  OK...glad you sorted it..but am curious what phpinfo has reported wink
                  phpinfo reports 5.0.67 as well. The query error must have been purely down to me using old/incorrect parameters with Ditto.

                  Quote from: kp52 at Jun 05, 2009, 06:02 PM

                  Yes.
                  Thanks for the helpful info.

                  Really pleased to get such great help here - thanks very much!
                    • 16183
                    • 1,390 Posts
                    OK, thanks.

                    /k
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      phpinfo() only reports the client library that php is using to access your mysql server, which may be a different version. phpmyadmin will report both client and server, and the more recent versions of MODx also report the mysql server version in the Reports -> System info page.
                        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