\RedBeanPHP\UtilQuickExport

Quick Export Utility

The Quick Export Utility Class provides functionality to easily expose the result of SQL queries as well-known formats like CSV.

Summary

Methods
Properties
Constants
__construct()
operation()
csv()
No public properties found
No constants found
No protected methods found
$toolbox
N/A
No private methods found
$test
N/A

Properties

$toolbox

$toolbox : \RedBeanPHP\Util\Finder

Type

\RedBeanPHP\Util\Finder

$test

$test : 

Type

Methods

__construct()

__construct(\RedBeanPHP\ToolBox  $toolbox) 

Constructor.

The Quick Export requires a toolbox.

Parameters

\RedBeanPHP\ToolBox $toolbox

operation()

operation(  $name,   $arg1,   $arg2 = TRUE) 

Makes csv() testable.

Parameters

$name
$arg1
$arg2

csv()

csv(string  $sql = '', array  $bindings = array(), array  $columns = NULL, string  $path = '/tmp/redexport_%s.csv', boolean  $output = TRUE, array  $options = array(',', '"', '\\')) : void

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.

Parameters

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