title: zf2 select columns from joined tables - how?
body: <p>I feel like I must me missing something very simple. It's a very simple task, all I want to do is get something like:</p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT * FROM lookup_items
  JOIN lookup ON lookup_items.lookup_id = lookup.id
  </code></pre>
  
  <p>This returns all the columns for all the joined tables, in regular SQL. Here's my attempt in zf2:</p>
  
  <pre class="lang-php prettyprint-override"><code>$select = new Select();
  
  $select-&gt;from('lookup_items');
  $select-&gt;join('lookup', 'lookup_items.lookup_id = lookup.id');
  </code></pre>
  
  <p>The result set only includes the columns in 'lookup_items'. I've tried various ways to get the 'lookup' columns, including:</p>
  
  <pre class="lang-php prettyprint-override"><code>$select-&gt;columns(array('lookup_items.*', 'lookup.*'));
  </code></pre>
  
  <p>But they all just blow up. Surely there's a way to do this, and it's just so simple I'm missing it completely.</p>
  
  <p>I thought a simple example would be avoid confusion, but here's more code:</p>
  
  <pre class="lang-php prettyprint-override"><code>class LookupItemsTable extends AbstractTableGateway
  {
  public function getList($resource)
  {
      $system_name = str_replace('*', '%', strtoupper($resource));
  
      $joinTable = 'lookup';
  
      $select = new Select();
  
      $select-&gt;from($this-&gt;table);
      $select-&gt;join($joinTable, "{$this-&gt;table}.lookup_id = {$joinTable}.id");
  
      $where = array();
      $where[] = "{$this-&gt;table}.enabled is true";
      $where[] = "{$joinTable}.enabled is true";
      $where[] = "UPPER({$joinTable}.system_name) ilike '{$system_name}'";
  
      $select-&gt;where($where);
  
      $sort[] = 'sort_order ASC';
      $sort[] = 'value ASC';
      $select-&gt;order($sort);
  
      $rowset = $this-&gt;selectWith($select);
  
      return $rowset;
  }
  }
  </code></pre>
  
  <p>Where:</p>
  
  <pre class="lang-php prettyprint-override"><code>$resource = $this-&gt;params()-&gt;fromRoute('resource', 'BUSINESS');
  </code></pre>
  
  <p>And $this->table is 'lookup_items'. Really all I want to do is get columns from both joined tables. I guess there's a zf2 way to just make a straight SQL statement without all the OO falderal, so I could just force it that way. But I'd rather work within the framework as much as possible.</p>