Does PHP7's PDO ext read the entire result set into memory? : <p>I have noticed since I upgraded to PHP7 that some SQL statements no longer work and instead run out of memory.</p>

<p>I have this code:</p>

<pre><code>$query = Yii::$app-&gt;db-&gt;createCommand('select * from tbl_title')-&gt;query();
while ($row = $reader-&gt;read()) {
    var_dump($row);
    exit();
}
</code></pre>

<p>And Yii2's database abstraction is just an extremely thin layer over PDO's and does not do anything extra. <code>query()</code> does nothing extra except add a line to a log file (Yii2's) for profiling and <code>reader-&gt;read()</code> just calls the PDO stream's <code>fetch()</code> function.</p>

<p>But it runs out of memory quoting the size (space used) of my table, i.e. trying to allocate 385 MB of process memory:</p>

<blockquote>
  <p>Allowed memory size of 134217728 bytes exhausted (tried to allocate 385883840 bytes)</p>
</blockquote>

<p>As a spanner, if I use a query whose result set fits entirely in the 128 MB limit of the PHP process works.</p>

<p>So, has PHP7 changed and can I change it back?</p>
