title: Codeigniter SELECT from another table as an array
body: <p>What i was hoping i would break some functions down and skipping running multiple queries all the time.</p>
  
  <p>Now if i have a ONE-to-MULTI relationship between two tables.
  <code>tbl_invoices</code> and <code>tbl_invoice_items</code>. Table <code>tbl_invoice_items</code> has a different row for each item for a specific order.</p>
  
  <p>Would it be possible with a SINGLE query from Codeigniter to get the item from the <code>tbl_invoices</code> and all the <code>tbl_invoice_items</code> in an array in the same result ?</p>
  
  <p>Basically JOIN the below queries</p>
  
  <pre><code>$this-&gt;db-&gt;select('*,tbl_invoices.id AS invoice_id');
  $this-&gt;db-&gt;from('tbl_invoices');
  $this-&gt;db-&gt;where('tbl_invoices.id',$invoice_id);
  $data = $this-&gt;db-&gt;get();
  
  
  $this-&gt;db-&gt;select('*');
  $this-&gt;db-&gt;from('tbl_invoice_items');
  $this-&gt;db-&gt;where('tbl_invoice_items.invoice_id',$invoice_id);
  $this-&gt;db-&gt;join('tbl_products','tbl_products.id = tbl_invoice_items.item_id','left');
  $data = $this-&gt;db-&gt;get();
  </code></pre>
  
  <p>Also would it be able in a ONE-to-ONE relationship tables return the other table as a custom variable ?
  Something like:
  <code>SELECT tbl_clients.* AS client, tbl_invoices.* FROM...JOIN...WHERE...etc</code></p>