$toolbox
$toolbox : \RedBeanPHP\ToolBox
Quick Export Utility
The Quick Export Utility Class provides functionality to easily expose the result of SQL queries as well-known formats like CSV.
$toolbox : \RedBeanPHP\ToolBox
__construct(\RedBeanPHP\ToolBox $toolbox)
Constructor.
The Quick Export requires a toolbox.
\RedBeanPHP\ToolBox | $toolbox |
csv(string $sql = '', array $bindings = array(), array $columns = NULL, string $path = '/tmp/redexport_%s.csv', boolean $output = TRUE, array $options = array(',', '"', '\\')) : string|NULL
Exposes the result of the specified SQL query as a CSV file.
Usage:
R::csv( 'SELECT
name
,
population
FROM city
WHERE region = :region ',
array( ':region' => 'Denmark' ),
array( 'city', 'population' ),
'/tmp/cities.csv'
);
The command above will select all cities in Denmark and create a CSV with columns 'city' and 'population' and populate the cells under these column headers with the names of the cities and the population numbers respectively.
string | $sql | SQL query to expose result of |
array | $bindings | parameter bindings |
array | $columns | column headers for CSV file |
string | $path | path to save CSV file to |
boolean | $output | TRUE to output CSV directly using readfile |
array | $options | delimiter, quote and escape character respectively |