title: PHP: MySQL query returning array
body: <p>I'm wondering how I would issue a query from a PDO and have an array returned? Right now, I have</p>
  
  <pre><code>$DBH = new PDO("mysql:host={$host};dbname={$dbname}", $user, $pass);
  </code></pre>
  
  <p>Using a foreach loop, like so</p>
  
  <pre><code>$query = "SELECT DISTINCT City FROM Locations ORDER BY City";
  foreach($DBH-&gt;query($query)as $row) {
      echo $row['City'];      
  }
  </code></pre>
  
  <p>I can get all the cities printed. However, I would like to store all the cities into an array. I tried to do it like this</p>
  
  <pre><code>$array = $DBH-&gt;query($query);
  </code></pre>
  
  <p>but that didn't work at all. Any suggestions?</p>