title: PHP Symfony 4 Export CSV
body: <p>I tried to create a CSV export feature for my website. I got error: "argument passed to _construct() must be an instance of PDOStatement".
   Below is the code (php symfony 4) - please advise. Thank you!</p>
  
  <pre><code>&lt;?php
  
  use Exporter\Handler;
  use Exporter\Source\PDOStatementSourceIterator;
  use Exporter\Writer\CsvWriter;
  
  // Prepare the data source
  $em=$this-getDoctrine()-&gt;getManager();
  $sql="select id, name from table";
  $stm= $em-&gt;getConnection()-&gt;prepare($sql);
  $stm-&gt;execute();
  
  $source = new PDOStatementSourceIterator($stm);
  
  // Prepare the writer
  $writer = new CsvWriter('data.csv');
  
  // Export the data
  Handler::create($source, $writer)-&gt;export();
  
  ?&gt;
  </code></pre>