We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38666
    • 98 Posts
    In the past I have used CreateXpdoClasses to handle custom tables, recently I have used ClassExtender to extend the user data. This has prompted the expected question from my client; could we add their company/laboratory affiliation to the user record.
    Can a related custom Company table be added to the schema created by ClassExtender or is it better to use the schema created with CreateXpdoClasses?

    This question has been answered by BobRay. See the first response.

      Give a man the answer, and he’ll only have a temporary solution. Teach him the principles that led you to that answer, and he will be able to create his own solutions in the future.
    • discuss.answer
      • 3749
      • 24,544 Posts
      If you want to add just user-related data (i.e., there is a one-to-one relationship between users and table rows), I think ClassExtender is a better option. You shouldn't need a new table, just a new column in the existing one (assuming that you've already run ClassExtender to extend modUser).
        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
        • 38666
        • 98 Posts
        Thanks again Bob, this is a borderline case as most are one to one but in some instances there may be several analysts per company but at the moment, and unlikely to change the most is four. I don't think that this situation will overload the extended user table so I'll just add Company name and address fields.

        Just for future reference and to clarify things in my mind, will ClassExtender support related tables in a many to one relationship?

        Jim
          Give a man the answer, and he’ll only have a temporary solution. Teach him the principles that led you to that answer, and he will be able to create his own solutions in the future.
          • 3749
          • 24,544 Posts
          Yes and no. You could certainly have more than one user with the same Company name and/or address field, but the userdata_id field must be unique so that each record is for a unique user and is the only record for that user.
            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
            • 38666
            • 98 Posts
            Got it thanks!
              Give a man the answer, and he’ll only have a temporary solution. Teach him the principles that led you to that answer, and he will be able to create his own solutions in the future.