title: How can I simply return objects in PDO?
body: <p>Trying out PDO for the first time.</p>
  
  <pre><code>$dbh = new PDO("mysql:host=$hostname;dbname=animals", $username, $password);
  
  $stmt = $dbh-&gt;query("SELECT * FROM animals");
  $stmt-&gt;setFetchMode(PDO::FETCH_INTO, new animals);
  
  foreach($stmt as $animals)
  {
      echo $animals-&gt;name;
  }
  </code></pre>
  
  <p>If i skip the <code>setFetchMode()</code> method, then I need to call <code>$animals["name"]</code> which I do not want.</p>
  
  <p>But I do not want to call the <code>setFetchMode()</code> for each query I do.</p>
  
  <p>Is there a way to set the default FetchMode ? Or some other method to make the <code>query()</code> return objects with one global setting.</p>