Displaying fields from my content types in a module
The best way would be to grab just the node ids from the table, and use the node_load_multiple() function to load the node objects. 

The field data will be attached to those objects, and you can use other API functions to extract the data/build the display HTML (field_get_items() and field_view_field() respectively).

Some sample code that should help:

function photo_gallery_contents($display){
  $max_num = variable_get('photo_gallery_max', 3);

  $query = db_select('node', 'n')
    -&gt;fields('n', array('nid'))
    -&gt;condition('status', 1) //Published.    
    -&gt;condition('type','portfolio') // Only want our photos aka Portfolio content type
    -&gt;orderBy('created', 'DESC'); //Most recent first.

  if ($display == 'block') {
    // Restrict the range if called with 'block' argument
    $query-&gt;range(0, $max_num);
  }

  // Fetch the results for the nid field into an array
  $nids = $query-&gt;execute()-&gt;fetchCol(); 

  // Load the node objects and return
  return node_load_multiple($nids);
}

function _photo_gallery_page() {
  $result = photo_gallery_contents('page');

  //Array to contain items for the page to render.
  $items = array();
  //Iterate over the resultset and format as links.
  foreach ($result as $node) {
    // Build a render array based on the field's display settings.
    $image = field_view_field('node', $node, 'field_image');

    // Render the array down to the image HTML
    $image_html = drupal_render($image);

    $items[] = array(
      'data' =&gt; l($image_html, 'node/' . $node-&gt;nid, array('html' =&gt; TRUE)),
    ); 
  }
}