We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33101
    • 46 Posts
    I wondering if there are any specific features that make xpdo a better choice over other ORMs - I’m familiar with Kohana’s ORM and I’ve read up about Doctrine and I’m wondering if there is a compelling reason to switch.
      • 13481
      • 97 Posts
      xpdo is much easier to use than doctrine or propel. it doesn’t have all the fancy features, but I like how it’s lightweight and has a lower learning curve.

      James
        • 22303 MODX Staff
        • 10,725 Posts
        Quote from: yehosef at Aug 09, 2010, 04:48 PM

        I wondering if there are any specific features that make xpdo a better choice over other ORMs - I’m familiar with Kohana’s ORM and I’ve read up about Doctrine and I’m wondering if there is a compelling reason to switch.
        The extremely small footprint and agile performance of xPDO is in my biased opinion the most important feature advantage. Most O/RM systems also include a DBAL, but xPDO simply acts as a wrapper class for PDO for the DBAL. I also tried not to model it directly on other O/RM systems and tried to focus on what got the most functionality with the least amount of code without sacrificing extensibility.

        The best way to know if it’s right for you is to try it out, or review the MODx Revolution code (the new modX class extends the xPDO class directly) and see how it has been used as the foundation for that application.
          • 32699 ☆ A M B ☆
          • 427 Posts
          I am switching some of my older projects from mysqli to xpdo. Even though that is not an ORM, the fact I can not code in one day what used to take me two weeks is all I needed to be sold on xPDO.

          The code is tiny, security is mostly handled and all the code has a very consistent field to it, even with a wide array of queries sitting there.

            Get your copy of MODX Revolution Building the Web Your Way http://www.sanitypress.com/books/modx-revolution-building-the-web-your-way.html

            Check out my MODX || xPDO resources here: http://www.shawnwilkerson.com
            • 33101
            • 46 Posts
            Thanks for the replies - I don’t have experience with Doctrine - just read about it. I have quite a bit of experience with Kohana’s ORM. When I first read about xpdo - it seemed much more complicated to get up and running - I haven’t tried xpdo, just looked at the docs. Does anyone have any experience with Kohana’s ORM (or Kohana Jelly) to compare/contrast. I find the Kohana syntax _much_ simpler and more intuitive, but I know there are some issues limitation with it (at least ORM, Jelly’s supposed to be the bees knees as it were) that perhaps makes xPDOs more complex syntax worth it.
              • 22303 MODX Staff
              • 10,725 Posts
              Quote from: yehosef at Aug 15, 2010, 05:57 PM

              Thanks for the replies - I don’t have experience with Doctrine - just read about it. I have quite a bit of experience with Kohana’s ORM. When I first read about xpdo - it seemed much more complicated to get up and running - I haven’t tried xpdo, just looked at the docs. Does anyone have any experience with Kohana’s ORM (or Kohana Jelly) to compare/contrast. I find the Kohana syntax _much_ simpler and more intuitive, but I know there are some issues limitation with it (at least ORM, Jelly’s supposed to be the bees knees as it were) that perhaps makes xPDOs more complex syntax worth it.
              Perhaps we should start with examples of how you feel xPDO’s syntax is more complex. IMO, xPDO’s syntax is much simpler, but I’m curious as to why you have made this assertion.
                • 33101
                • 46 Posts
                Before getting to the syntax, we’ll start with the terminology:
                xPDOManage, xPDOGenerator,xPDOCriteria, xPDOQuery - I’m already getting dizzy.

                Perhaps if you can give me the xPDO needed to do the following I’ll see the difference.

                Assume a schema of a
                blog table with an id, title
                post table with id, blog_id, author_id, title, text
                author table with id, name, email

                // with KO3 syntax (approximately - not testing)
                class Model_Blog extends ORM {
                protected $_has_many = array(’posts’=>array());
                }
                class Model_Post extends ORM {
                protected $_belongs_to = array(’blog’=>array(),’author’=>array());
                }
                class Model_Author extends ORM {
                protected $_has_many = array(’posts’=>array());
                }

                now I can do

                $post = ORM::factory(’post’,$id);
                $post->text = ’something’;
                $post->title = ’title’;
                $post->save();

                or
                $blog = ORM::factory(’blog’)->where(’title’,’=’,’my blog’)->find()
                $author_id = ORM::factory(’user’)->where(’email’,’=’,’[email protected]’)->find()->id
                $my_author_posts = $blog->posts->where(’author_id’,’=’,$author_id)->find_all();
                // if you were desperate you could combine the above lines into one

                Kohana has been built with php5 from the beginning so it makes good use of magic methods, chaining, SPL. I remember that xpdo was php4 and I understand ta at some point it moved to php5, but I’m not sure if the methodology moved also (eg, I don’t think I’ve seen any use of __get/__set or chaining).

                Again, it might be that there are things that xpdo can handle that ORM would have a hard time with. That’s why I’m asking.

                  • 33101
                  • 46 Posts
                  Just as an additional note - the kohana ORM requires no special building or preparation - you just make your DB tables with the right naming conventions (which can be overridden) and tell the models what relates to what and you’re good to go. There’s no YAML, XML markup or any extra definitions that need to be done. Very fast and simple. From what I read of xPDO the process is more complicated and verbose, but I’d be happy to see an example of the above relations and actions in xPDO to understand how better it works.