title: Returning a lot of rows in CakePHP & MySQL
body: <p>Maybe I'm missing something easy here...or maybe I've just been coding on this so long I can't see past my problem, but using CakePHP (1.3) and doing a select (MySQL) should be able to return results even if there are, say, 2,000 records... right?</p>
  
  <pre><code>$options = array(
      'conditions' =&gt; array(
          'Lead.campaign_id' =&gt; $campaign['Campaign']['id']
      ),
      'recursive' =&gt; -1,
      'order' =&gt; 'Lead.goal DESC',
      'contain' =&gt; false,
  );
  
  $leads = $this-&gt;Lead-&gt;find('all',$options);
  </code></pre>
  
  <p>Yet, this query gives me a white screen of death (with <code>define('LOG_ERROR', 2);</code> set).</p>
  
  <p>If I add a <code>'limit' =&gt; 300,</code> (or similar number..doesn't have to be exactly 300) to the <code>$options</code> array then it will pull results so I know the query itself isn't the problem.</p>
  
  <p>Additionally, I've tried to limit the columns returned by using the <code>'fields'</code> parameter in the <code>$options</code> array...even telling it to only return 1 field but that didn't work either.</p>
  
  <p>I've also echoed out the SQL statement that it uses via</p>
  
  <pre><code>$log = $this-&gt;Lead-&gt;getDataSource()-&gt;getLog(false, false);
  debug($log);
  </code></pre>
  
  <p>Of course, I had to put the <code>'limit'</code> in for that to show up (otherwise I just get the white screen of death). Then I copy/paste that query (without the limit) into phpMyAdmin and it returns the records just fine (even with 'show me 1,000 rows' on). Doing this leads me to believe that the system <em>can</em> handle the query &amp; output but maybe I'm making an assumption I shouldn't be.</p>
  
  <p>The reason I'm trying to get all rows and not paginate the records is because I need to output them to a csv file for download by the user (this part is already working... <em>when</em> the query works).</p>
  
  <p>It was suggested to me that it's probably a timeout issue and I should just raise that but that seems like a hack to me and there must be a better solution.</p>
  
  <p>Since I'm doing a download of a csv file maybe there's a way for me to stream the query to a file that then gets downloaded? Or perhaps there's even a better solution?</p>