We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27733
    • 99 Posts
    Is there a method to do the above, or would I need to loop through the object and build an array in the usual fashion?
      ------
      Server: *nix, ModX Evo 1.0.4, Apache 2.x, PHP 5.x, Mysql 5.x.
      • 21120
      • 30 Posts
      Both of those methods already return an array of objects. If you want to turn the object fields into an array, you can use toArray().

      http://rtfm.modx.com/display/xPDO20/toArray
        • 27733
        • 99 Posts
        Yes, but what I’m getting at is a method which converts the entire result into a pure multidimensional array ...
          ------
          Server: *nix, ModX Evo 1.0.4, Apache 2.x, PHP 5.x, Mysql 5.x.
          • 21257 MODX Staff
          • 730 Posts
          There is no method to do that, but you could add one, based on loadCollection.
          Where loadCollection gets $rows back from the _loadRows() method, then proceeds to iterate the $rows, instantiating objects and adding them to the collection, you could change it to build up your array instead.
          You might create a new class, extending xPDOObject or xPDOSimpleObject, and add your new method to that (those). Then in your own xpdo model, you could just extend your new custom classes.
            Mike Schell
            Lead Developer, MODX Cloud
            Email: [email protected]
            GitHub: https://github.com/netProphET/
            Twitter: @mkschell