title: Why is the expression in this while loop causing an infinite loop?
body: <p>New to oop and was just wondering why this causes an infinite loop:</p>
  
  <pre><code>while ($row=$dbh-&gt;query("SELECT * FROM animal")-&gt;fetch(PDO::FETCH_ASSOC)){
      printf("A(n) %s is a type of %s&lt;br /&gt;", $row['name'], $row['species']);
  }
  </code></pre>
  
  <p>However this does not cause an infinite while loop</p>
  
  <pre><code>$sth=$dbh-&gt;query("SELECT * FROM animal");
  while ($row=$sth-&gt;fetch(PDO::FETCH_ASSOC)){
      printf("A(n) %s is a type of %s&lt;br /&gt;", $row['name'], $row['species']);
  }
  </code></pre>