title: Flow: Convert object to array for CSV export
body: <p>I want to export my object "mitglied" to a .csv-file. My controller looks like that:</p>
  
  <pre><code>public function exportAction() {
  
      // find all mitglieds
      $records = $this-&gt;mitgliedRepository-&gt;findTennis();
  
      // Set path for export-file
      $csvPath = '/var/www/apps/flow/Packages/Application/ITOOP.Atc/Resources/Private/Export/test.csv';
  
      $fp = fopen($csvPath, 'w');
  
      foreach ($records as $lines) {
          fputcsv($fp, $lines);
      }
  
      fclose($fp);
  }
  </code></pre>
  
  <p>When I call the exportAction, I get a an error:</p>
  
  <blockquote>
    <p>#1: Warning: fputcsv() expects parameter 2 to be array, object given in /var/www/apps/flow/Data/Temporary/Development/Cache/Code/Flow_Object_Classes/itoop_atc_Controller_MitgliedController.php line 494</p>
  </blockquote>
  
  <p>line 494 is...</p>
  
  <pre><code>fputcsv($fp, $lines);
  </code></pre>
  
  <p>...so I think I have to convert the object "mitglied" to an array.</p>
  
  <p>My the public function <code>findTennis</code> in my mitgliedRepository looks like that:</p>
  
  <pre><code>public function findTennis() {
      $query = $this-&gt;createQuery();
      $result = $query-&gt;matching($query-&gt;equals('abteilung', 'Tennis'))
                      -&gt;setOrderings(array('name' =&gt; \TYPO3\Flow\Persistence\QueryInterface::ORDER_ASCENDING))
                      -&gt;execute();
  
      return $result;
  }
  </code></pre>
  
  <p>I tried to set toArray(); in the repository like the that:</p>
  
  <pre><code>public function findTennis() {
      $query = $this-&gt;createQuery();
      $result = $query-&gt;matching($query-&gt;equals('abteilung', 'Tennis'))
                      -&gt;setOrderings(array('name' =&gt; \TYPO3\Flow\Persistence\QueryInterface::ORDER_ASCENDING))
                      -&gt;execute()
                      -&gt;toArray;
      return $result;
  }
  </code></pre>
  
  <p>But then I get the following error:</p>
  
  <blockquote>
    <p>#1: Notice: Undefined property: TYPO3\Flow\Persistence\Doctrine\QueryResult::$toArray in /var/www/apps/flow/Data/Temporary/Development/Cache/Code/Flow_Object_Classes/itoop_atc_Domain_Repository_MitgliedRepository.php line 105</p>
  </blockquote>
  
  <p>line 105 of course is</p>
  
  <pre><code> -&gt;toArray;
  </code></pre>
  
  <p>Does anybody know, how to convert an object to an array in flow?</p>
  
  <p>With the following example the export works, so I think the (formatting of the) repository query is the problem.</p>
  
  <pre><code>public function exportAction() {
      // Set path for export-file
       $csvPath = '/var/www/apps/flow/Packages/Application/ITOOP.Atc/Resources/Private/Export/test.csv';
  
   $test = array (
       array('xxx', 'bbb', 'ccc', 'dddd'),
       array('123', '456', '789'),
       array('aaa', 'bbb')
   );
  
  
   $fp = fopen($csvPath, 'w');
  
   foreach ($test as $lines) {
       fputcsv($fp, $lines);
   }
  
   fclose($fp);
  </code></pre>
  
  <p>}</p>
  
  <p>Please point me to the right direction. Thank you!</p>