We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37044
    • 68 Posts
    Hi
    I would like to think of myself as an established php / mysql developer and have been using modx for some time now - note not really via the api yet though.

    I have looked at some tutorials (http://rtfm.modx.com/display/xPDO20/Defining+the+Database+and+Tables) for example and still find the whole custom xpdo table thing a bit daunting.

    I could however confidently write the table I need to in standard mysql and then access the data using standard php and maybe some modx api.

    Its not going to be a massive table or very complicated.

    I am on quite a tight time frame hence am drawn to a standard mysql table but would hate to get further into the project and realize I have missed something with the xpdo tables or that they would have been a better approach...

    ...can any experienced users give me some basic pros and cons of either approach which they have encountered.

    Thanks
    Steve
      • 3749
      • 24,544 Posts
      Using xPDO will let you access the data in very easy, flexible ways since any xPDO-aware tables will allow you to use all the xPDO get*() methods. You'll also get the built-in xPDO caching and your code will be more compact and easier to maintain. You'll also get engine-independence, because xPDO can work with non-MySQL DBs (Microsoft MS SQL is implemented and others are on the roadmap).

      If you already have the table(s) and (especially) if there are no complex relationships between tables, this might be an easier approach to xPDO-ifying things: http://bobsguides.com/custom-db-tables.html.

      FYI, you can create the table(s) and the traditional code to work with them now and implement the xPDO layer for it later. There's nothing special about xPDO tables themselves or the data in them. They're standard MySQL (or whatever) tables.

      There's a quick intro to MODx objects here that shows some of the elegance of the xPDO methods: http://bobsguides.com/revolution-objects.html
        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
        • 37044
        • 68 Posts
        Thanks BobRay.

        Although I understand the concepts of xPDO to me moving away from the classic mysql that I am well versed in seems like a big step for not a great amount of gain.

        For the sites I am developing xPDO seems like it could prove more of a hindrance to me which might indicate that I still do not appreciate the full advantages of using it...

        Also using xPDO means I would loose using phpmyadmin which is a great tool. If you have a large xpdo table and other complicated structures how do you browse it? Is there any kind of db viewer / manager that I have not heard of? Using phpmyadin is a such an easy effective way to brows and visualize your data I would hate to lose it.

        Also could you tell me what table within modx data from a custom xpdo function is written to?

        Once again thanks. [ed. note: megasteve4 last edited this post 14 years, 9 months ago.]
          • 33968
          • 863 Posts

          Also using xPDO means I would loose using phpmyadmin which is a great tool.
          No way smiley I use xPDO for everything now but would not get far without phpMyAdmin. I use it every day. Why did you think you wouldn't be able to use it? Perhaps we can clarify for you.

          xPDO is an abstraction layer that allows you quick and easy access to your data and the relationships between tables. But at the end of the day it's all just php and mySql under the hood, nothing's changed there.

          Try out the Doodles tutorial. Just the first Section is enough to get you started with xPDO. Don't just read through it though, try it out wink [ed. note: okyanet last edited this post 14 years, 9 months ago.]
            • 37044
            • 68 Posts
            @Lucas thanks for the prompt reply

            I'm starting to feeling like i have missed something here...

            I have tried the Doodles tut before but did not get past the 'Making the Magic Path Settings'...

            So can you please clarify if I 'had' set up Doodles correctly it would actually create a specific mysql table for the doodles extra and then the doodles class would just interact directly with that. I was of the impression that the data would be stored in some 'black box' modx data structure rather than a classic mysql table.

            Please bear with me I am pretty new to the concept of xPDO!

            Thanks.
              • 36620
              • 65 Posts
              I can understand the need for xPDO if creating an extra but it seems awfully complicated and time-consuming if it's not for an extra. Plus it would mean if you moved away from MODX you would have write code for the the custom-table all over again.

              One of the reasons I've stuck with Evo is the simplicity of using eForm with a custom tables. Even non-programmers like me can follow those tutorials. smiley
                • 33968
                • 863 Posts
                Quote from: megasteve4 at Jan 22, 2012, 06:13 PM

                So can you please clarify if I 'had' set up Doodles correctly it would actually create a specific mysql table for the doodles extra and then the doodles class would just interact directly with that.
                Yep, exactly this. You'll create a 'build' script that will auto-generate all the class files, and once you have this creating your table is as simple as:
                $m = $modx->getManager();
                $created = $m->createObjectContainer('Doodle');
                return $created ? 'Table created.' : 'Table not created.';
                

                What went wrong with your Magic Path settings?

                @randall - you can always try out the rowBoat snippet which will let you explore data in a custom table without having to go through the effort of setting up the schema and class files smiley