fulfillment/periscope-to-mysql

Take your Periscope SQL and generate MySQL statements.

0.0.2 2016-03-11 23:01 UTC

This package is not auto-updated.

Last update: 2024-04-24 22:01:22 UTC


README

periscopedata.com is a powerful and useful tool for generating reports, but sometimes I want to put what I write in Periscope to use elsewhere. This package allows you to write once but generate MySQL statements with filters and daterange within PHP.

Limits

You bet...

  • UTC is assumed to be used by your DB
  • Always converts to EST
  • Unaware of foreign keys = unable to automatically join tables

Example

use Fulfillment\periscopeToMySQL\periscopeToMySQL;

$args = [
    'dateStart' => "2016-01-01",
    'dateEnd'   => "2016-03-11",
    'Warehouse' => "1,2,3",
    'State'     => "GA",
];

$sql = 'SELECT
            [yourFirstTable.aDate:est] AS aDate,
            yourSecondTable.part2
        FROM
            yourFirstTable
            JOIN yourSecondTable ON yourFirstTable.id = yourSecondTable.id
        WHERE
            [yourFirstTable.recordedOn=daterange:est]
            AND [yourFirstTable.warehouse=Warehouse]
            AND [yourSecondTable.state=State]';

$sql = periscopeToMySQL::fillTemplate($sql, $args);

Installation

WARNING: this project is still in development

Composer

composer require fulfillment/periscope-to-mysql
"require": {
    "fulfillment/periscope-to-mysql": "dev-master"
}

Local

"repositories": [
    {
        "type": "path",
        "url": "../periscope-to-mysql"
    }
],
"require": {
    "fulfillment/periscope-to-mysql": "dev-master"
}

Contribute

Feel free, time zone support may be a good place to start.