<?php
session_start();
	
require "conexao.php";

 
	$destino = '/util/dadosnfe/dadosnfe.csv'; 

	@unlink("$destino"); 
	
	$sql = "SELECT * INTO OUTFILE '/util/dadosnfe/dadosnfe.csv'
		FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY ''
		LINES TERMINATED BY '\n'
		FROM dadosdevolucao";
	
	$result = mysqli_query($conexao, $sql);


	require_once 'baixardadosnfe.php';


	$_SESSION['msg'] = "<div class='alert alert-success'>Exportado para pasta util</div>";
	//header("Location: ../buscardadosnfe.php");