We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37654
    • 39 Posts
    Hello,

    I don't figure how to query Gallery tables with xPDO.

    This is stupid, but i can't get a simple request like this to work:
    SELECT * FROM modx_gallery_album_items WHERE album=1;

    Thanks.
      • 33968
      • 863 Posts
      What have you tried?
        • 37654
        • 39 Posts
        A lot of things, but i'm not familiar with xPDO.
        I'm completely stuck atm.
          • 37654
          • 39 Posts
          Finally i've done it with regular PDO, but i'm still curious to see how xPDO can help me in this case...
            • 34012
            • 88 Posts
            This is not straight forward with xPDO unless you have knowledge of the core of the extra in this case.

            To build xPDO query you have to view the XML file that comes with the extra to see the object names, optionally you can check the /model/gallery/ directory for the class names to query at.

            xPDO constructs query based on the actual class objects and not the table names. The query itself is pretty simple:
            $galleries = $modx->getCollection('Gallery');
            foreach($galleries as $gallery) {}


            With exception that I do not remember the real names of the classes top of me head.

            I do encourage to join the "xPDO" family which can take bit of time, but you can read how to build queries from the RTFM, my site or Bob's site. Mine and RTFM can most likely answer quite lot of questions right now. And am trying to finalize the next chapter for lazybook which will have quite lot of SQL queries turned to xPDO queries.

            If you want to get objects with xPDO query, you can use xPDOCriteria object to build the query and you can find example from my site, a small article that was my first xPDO related article.
              Almost retired from web-development industry but still randomly writing at Lazylegs.info and on schedule hopefully in near future to finish Oracle and PostgreSQL ports of MODX