GraphUtils::getPeriodSql

Usage

array GraphUtils::getPeriodSql(string $column, int $num, string $period, [ string $start_date = '' ], [ bool $is_graph = false ])

Description

Gets the WHERE clause of the SQL statement for the appropriate time periods that will be viewed within the graph / report.

Parameters

Parameter Required Type Description
$column Yes string Column name of the date column (eg. created_at)
$num Yes int The number of items (eg. days, months, years) that will be retrived / displayed.
$period Yes string The date period that is being displayed. Support values are, 'day', 'week', 'month', 'quarter', 'year'
$start_date No string The date where the graph / report will start. If left blank, will use the current date.
$is_graph No bool Boolean as to whether this is a graph or table

Return Value

An array consisting of three variables -- the WHERE clause of the SQL statement, the start date formatted to display in the web browser, and the start date in YYY-MM-DD format.

Examples

Get Period Sql


list($where_sql, $display_date, $date) = $graph_utils->getPeriodSql('created_at', 25, 'month');

See Also