ajax - How to get query result as csv with column names in symfony php -


i have requirement query result in csv , should downloadable button click. using php symfony framework database interaction. can help me how approach achieve this? thankful

please provide more information, "the query result" – query, how result looks like.

if you're using @ least symfony 3.2, can use build-in csv encoder.

then should return object instance of \symfony\component\httpfoundation\response.

for example:

$csvcontent = $container->get('serializer')->encode($result, 'csv');  return new \symfony\component\httpfoundation\response(     $csvcontent,     \symfony\component\httpfoundation\response::http_ok,     [         'content-type' => 'text/csv'     ] ); 

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -