title: PDO associative arrays - return associative
body: <p>I have this code:</p>
  
  <pre class="lang-php prettyprint-override"><code>$dbInstance = DB_Instance::getDBO();
  $statement = $dbInstance-&gt;prepare("SELECT id, name FROM language ORDER BY id");
  $statement-&gt;execute();      
  $rows = $statement-&gt;fetchAll(); 
  
  //Create associative array wuth id set as an index in array
  $languages = array();
  foreach($rows as $r) {
      $languages[$r['id']] = $r['name'];
  }
  return $languages;
  </code></pre>
  
  <p>I can't figure out how to use PDO-statement to achieve the same result that array $languages produces. I've tried some different fetch_styles.</p>
  
  <p>I've tried some different styles and I could get like:</p>
  
  <pre><code>[0] svenska
  [1] engelska
  </code></pre>
  
  <p>but I want like:</p>
  
  <pre><code>[1] svenska
  [2] engelska
  </code></pre>
  
  <p>(where 1 and 2 are the values of id in database)</p>
  
  <p>I guess I could create a function and call that with <code>FETCH_FUNC</code> but I'm not sure that would be so great either.</p>
  
  <p>Is the above the best/cleanest way to do it?</p>