\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

$test

$test : boolean

Type

boolean

Methods

__construct()

__construct(\RedBeanPHP\ToolBox  $toolbox) 

Constructor.

The Quick Export requires a toolbox.

Parameters

\RedBeanPHP\ToolBox $toolbox

operation()

operation(string  $name, mixed  $arg1, boolean  $arg2 = TRUE) : mixed

Makes csv() testable.

Parameters

string $name
mixed $arg1
boolean $arg2

Returns

mixed

csv()

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.

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

Returns

string|NULL