vasilisq/mdx-query-builder

MDX Query Builder

1.0.1 2019-05-23 10:45 UTC

This package is auto-updated.

Last update: 2024-04-23 21:39:46 UTC


README

Provides convenient query builder for MDX. Supports several features of Mondrian MDX specification.

Usage

Implement ConnectionInterface and pass it into Query.

You can use Olap4Php and pass MDX-string build by Query class into XMLAStatement.

An example of query can look like this:

$query = new Query($connection);

$dateRange = new DateRange(
    Carbon::parse('2019-01-01'),
    Carbon::parse('2019-01-31'),
    Period::DAY
);

$mdx = $query->select([
        '[Measures].[Retail Total]',
        '[Measures].[Profit]',
    ])
    ->by($dateRange)
    ->from('Sales')
    ->toMDX();

Resulting MDX is:

SELECT 

{[Measures].[Retail Total], [Measures].[Profit]} ON COLUMNS,

{
    {[Time].[2019].[Q1].[1].[W1].[D1] : [Time].[2019].[Q1].[1].[W5].[D31]}
} ON ROWS 

FROM [Sales]

TODO: Abstract Query class from Mondrian dialect