We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44109
    • 12 Posts
    Hi all,
    I am using Evo 1.10.
    I need to perform an sql select statement that needs to join two tables.
    Is this possible to do with DBAPI select command? I could not find any examples.

    Thank you
      • 4041
      • 788 Posts
      Maybe this will help smiley
      $sql= "SELECT wu.username, wua.*
             FROM " . $modx->getFullTableName( "web_users" ) . " wu
             INNER JOIN " . $modx->getFullTableName( "web_user_attributes" ) . " AS wua ON wua.internalKey=wu.id
             WHERE wu.id='$uid'";
      
      $row = $modx->db->getRow( $modx->db->query( $sql ) );
      
      if( $row ){
                      
          // code here
      }
      
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 44109
        • 12 Posts
        Thank you very much for your reply.
        I was aware of the API:DBAPI:query() function, but I was somehow put off by the following words in the documentation:
        It is recommended to use the specific database function to run your queries (such as using $modx->db->select() to perform a SELECT query) instead of using this function, when possible. This function is intended for "internal use only", which means that it is intended for use by the database functions.
        But if this is the way you would choose to do it then I should follow it too.

        Thanks again
          • 4041
          • 788 Posts
          I found that code being used in the weblogin snippet (which was created by coders with much more experience than myself), and it works fine for me in other applications, your mileage may vary smiley
            xforum
            http://frsbuilders.net (under construction) forum for evolution