We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 225
    • 3 Posts
    I’m still trying to wrap my head around this whole xPODQuery stuff and after having read multiple threads, traversing the wiki and other sources, my head is about to explode. I think my brain is making it a lot harder than it is...

    I need to get the data from this SQL Query:

    SELECT
    producttbl.productName,
    producttbl.productDescUK,
    producttbl.productDescDK,
    versiontbl.versionName
    FROM
    producttbl
    INNER JOIN productversiontbl ON producttbl.productID = productversiontbl.productIDFK
    INNER JOIN versiontbl ON versiontbl.versionID = productversiontbl.versionIDFK


    Do I have to go the full route described http://rtfm.modx.com/display/revolution20/Using+Custom+Database+Tables+in+your+3rd+Party+Components"" target="_blank" rel="nofollow">here
    or am I simply missing the obvious?
      • 22303 MODX Staff
      • 10,725 Posts
      xPDOQuery is for if you want to go the full object/relational model route and generate classes to represent your tables. If all you want to do is execute a query, use the built-in PDO methods:
      <?php
      $stmt= $modx->query("SELECT
      producttbl.productName,
      producttbl.productDescUK,
      producttbl.productDescDK,
      versiontbl.versionName
      FROM
      producttbl
      INNER JOIN productversiontbl ON producttbl.productID = productversiontbl.productIDFK
      INNER JOIN versiontbl ON versiontbl.versionID = productversiontbl.versionIDFK");
      
      if ($stmt) {
          while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
              // do stuff with a row here...
          }
      }
      ?>
        • 225
        • 3 Posts
        That’s just embarrassingly too easy...

        Thanks a bunch!