We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14281
    • 120 Posts
    I tested Jot 1.0.1 using it’s own default templates for form and comment list. Everything is submitted well enough, but when the custom fields are placed in the DB, they are given the ID of 1, instead of the ID of the comment they should go with. This, obviously, prevents them from working properly.
      • 4195
      • 398 Posts
      i think we have to go more detailed on your problem because you are the first that has this problem wink
        Armand Pondman
        MODx Coding Team
        :: Jot :: PHx
        • 14281
        • 120 Posts
        Each comment is given a unique ID. The custom fields, as you know, are stored in a separate table, with a foreign key that identifies itself with the primary key of the appropriate comment. Using the default installation, with default templates, when I submit a comment, the custom fields are placed in the DB, but with a foreign key of "1", rather than the ID of the comment.

        I’m using MySQL 4.1.21, PHP 5.1.4, and Apache 1.3.37

        My system has gotten complex enough to where this could be something that I’m missing on my end. I’ll continue to look into it.
          • 25663 MODX Staff
          • 12,272 Posts
          Most likely, it’s MySQL 4.1.21 ... seems to be lots of problems with that particular version: http://www.google.com/search?client=safari&rls=en&q=mysql+4.1.21+bug&ie=UTF-8&oe=UTF-8
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 14281
            • 120 Posts
            Well, I have about 5 MODx installs all running fine with it, except for this one problem with the latest version of Jot. It doesn’t seem like a particularly complicated or heavy task. It’s just placing a value into a field, and possibly pulling it out later to insert as a foreign key in another table, right?

            I wonder what Jot is doing that all the rest of the MODx code isn’t.

            What version of MySQL are you guys running?

            Thanks for the help.
              • 4195
              • 398 Posts
              Jot is using the default MODx dbapi. When writing a comment the basic record in jot_content table gets inserted first..
              The return value is the id of the inserted record..  the next inserts are made in the jot_fields table using the previous returned id.

              I have a feeling this is about the PHP version.. maybe the id variable is interpreted the wrong way and defaults to 1.
                Armand Pondman
                MODx Coding Team
                :: Jot :: PHx
                • 14281
                • 120 Posts
                So I never did get this issue worked out. I’ve stayed with Jot 1.0, which uses xml for custom fields. I made several attempts to solve this myself, but nothing seemed to do the trick. Until today.

                I’m not sure why this works for everyone else and not for me; based on my findings, I would’ve thought this wouldn’t work for anyone.

                The reason why the proper ID is not inserted into the fields table, is because the ID of the last comment is retrieved through the MODx API, which uses the php function mysql_insert_id() to retrieve the last ID generated by MySQL. This function requires a persistent connection to the database, because if the connection closes after the query is executed, the ID value will be incorrect.

                The connect() function in the DBAPI class is set to $persistent=0 by default. Every instance that I’ve found in the entire system that refers to this function does not do anything to change this. So it appears that the connection is never persistent.

                After all is said and done, this appears to work for most people, so there is obviously something that I’m missing. All I know is that once I changed the default value in this function to 1, the jot snippet worked correctly. The correct ID was retrieved, and the rest is history.

                The only question I have now is this: Setting the $persistent value to 1 by default will now cause every connection instance that the system makes to be persistent. Does anyone see any obvious problems this may cause?

                Also, perhaps a unique connection should be made by Jot which set this value to be persistent for that one instance. Because anytime I upgrade MODx, if I forget to set that value again, all comments will be screwed up until I do.