We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2602
    • 24 Posts
    So im having some issue trying to make a simple query using the bdapi in a snippet.


    <?php
    $myID = $modx->getLoginUserID();
    $table = $modx->getFullTableName("myTableHere");
    $dataQuery = $modx->db->select('*', $table, 'User_ID = '.$myID);
    
    
    echo '<pre>';
    print_r($dataQuery);
    echo '</pre>';
    ?>
    


    using the code above, the only output i get is "Resource id #21". Not sure what that means, but i should be getting a whole array full of data. Is there something wrong with my syntax?

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Not at all. You are getting exactly what you are supposed to be getting. You have to extract the data from the resource that the query returned. Use $modx->db->getRow($dataQuery) to get each row of data (this is usually done in a loop)
      while($row = $modx->db->getRow($dataQuery)) { print_r($row); }
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 2602
        • 24 Posts
        ah great. Thanks. One more line of code...