Ver Mensaje Individual
  #5 (permalink)  
Antiguo 16/12/2015, 10:37
Karmo
 
Fecha de Ingreso: marzo-2005
Mensajes: 51
Antigüedad: 19 años, 1 mes
Puntos: 0
Respuesta: Exportar query doctrine a archivo csv

Encontré la solución, la comparto!!

......

Código PHP:
Ver original
  1. use Symfony\Component\Filesystem\Filesystem;
  2. use Symfony\Component\Filesystem\Exception\IOExceptionInterface;

......

Código PHP:
Ver original
  1. $fs = new Filesystem();
  2.  
  3.     try {
  4.         $fs->mkdir('directorio/');
  5.         $fs->touch('directorio/file.csv');
  6.  
  7.         $handle = fopen('directorio/file.csv', 'w+');
  8.  
  9.        // $exportar -> es la array de mi query
  10.  
  11.         foreach ($exportar as $exportar => $value) {
  12.  
  13.             fputcsv($handle, $value);
  14.  
  15.         }
  16.  
  17.     } catch (IOExceptionInterface $e) {
  18.         echo "An error occurred while creating your directory ";
  19.     }