CSV Output

To create a CSV report on the fly use the method to("CSV") as shown below.



<?php
          \Reportico\Engine\Builder
::build()
              ...
              ...
              ->
to("CSV")
              ->
execute();
?>
1




<?php
      
require_once(__DIR__ .'/../vendor/autoload.php');
      

      
\Reportico\Engine\Builder::build()
          ->
properties([ "bootstrap_preloaded" => true])
          ->
datasource()->database("mysql:host=localhost; dbname=DATABASE NAME")->user("USER")->password("PASSWORD")
          ->
title     ("Product Stock")
          ->
description     ("Produces a list of our products")
          ->
sql       ("
              SELECT  ProductID id, ProductName product, UnitsInStock in_stock, UnitsOnOrder on_order, companyname Company, country, categoryname category
              FROM northwind_products 
              join northwind_suppliers on northwind_products.supplierid = northwind_suppliers.supplierid
              join northwind_categories on northwind_products.categoryid = northwind_categories.categoryid
              WHERE 1 = 1  
              ORDER BY categoryname
                "
)
          ->
group("category")
              ->
header("category")
              ->
throwPageBefore()
          ->
to"CSV" )
          ->
execute();
?>