2017-25 © Pedro Peláez
 

library phpolapi

A PHP API for XMLA to connect to OLAP databases

image

kabachello/phpolapi

A PHP API for XMLA to connect to OLAP databases

  • Wednesday, June 6, 2018
  • by Kabachnik
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 24 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

phpOLAPi - connect to OLAP databases via XMLA

Features:, (*1)

  • execute MDX statements over XMLA
  • use result data in PHP as an associative array
  • transform the result into other structures via plug-in renderers: e.g. an HTML table, CSV, etc.
  • create MDX queries in OOP-style via MDX query builder
  • explore database schemas (cubes, dimensions, hierarchies, levels, ...).

phpOLAPi is a fork of phpOLAP by Julien Jacottet, which is unfortunately not maintained anymore., (*2)

Install

composer require kabachello/phpolapi

phpOLAPi runs on PHP 5.3.2 and above., (*3)

Connect

``` php 'Provider=Mondrian;DataSource=MondrianFoodMart;' 'CatalogName' => 'FoodMart', 'schemaName' => 'FoodMart' ] ); // for Microsoft SQL Server Analysis Services $connection = new Connection( new SoapAdaptator('http://localhost/olap/msmdpump.dll', 'username', 'password'), [ 'DataSourceInfo' => null, 'CatalogName' => 'Adventure Works DW 2008R2 SE' ] ); ``` **NOTE:** Before you start, make sure, your database provides an XMLA webservice. Some OLAP enginges (like Mondrian) work with XMLA out of the box, while others require additional actions to be performed - for example, here are the official instructions to add an [XMLA webservice to Microsoft Analysis Services](https://docs.microsoft.com/en-us/analysis-services/instances/configure-http-access-to-analysis-services-on-iis-8-0). Run an MDX query ----- ``` php // Connect as shown above $connection = ... // Execute MDX statement $resultSet = $connection->statement(" SELECT [Measures].MEMBERS ON COLUMNS FROM [Adventure Works] "); // Transform to associative array $renderer = new \phpOLAPi\Renderer\AssocArrayRenderer($resultSet); $array = $renderer->generate(); ``` Build an MDX query via API ----- ``` php use phpOLAPi\Mdx\Query; $query = new Query("[Sales]"); $query->addElement("[Measures].[Unit Sales]", "COL"); $query->addElement("[Measures].[Store Cost]", "COL"); $query->addElement("[Measures].[Store Sales]", "COL"); $query->addElement("[Gender].[All Gender].Children", "COL"); $query->addElement("[Promotion Media].[All Media]", "ROW"); $query->addElement("[Product].[All Products].[Drink].[Alcoholic Beverages]", "ROW"); $query->addElement("[Promotion Media].[All Media].Children", "ROW"); $query->addElement("[Product].[All Products]", "ROW"); $query->addElement("[Time].[1997]", "FILTER"); $connection = ... $resultSet = $connection->statement( $query->toMdx() ); ``` Use ResultSet renderers ------ The result of a query is a `ResultSet` instance, which mimics the (very complex) structure of an XMLA response. Renderers help extract the actual data, which is burried deep in the XML. In the first example above we used the `AssocArrayRenderer` to transform the `ResultSet` into an associative array. But there are also other renderers and you can also build your own! ``` php use phpOLAPi\Renderer\Table\HtmlTableRenderer; use phpOLAPi\Renderer\Table\CsvTableRenderer; use phpOLAPi\Renderer\AssocArrayRenderer $connection = ... $resultSet = $connection->statement(" SELECT { [Measures].[internet Sales Amount], [Measures].[Internet Order Quantity] } ON COLUMNS, { [Date].[Calendar].[Calendar Year].[CY 2006], [Date]. [Calendar].[Calendar Year].[CY 2007] } ON ROWS FROM [Adventure Works] WHERE ([Customer].[Customer Geography].[Country].[Australia]) "); // Associative array (similar to the result of SQL queries) $array = (new AssocArrayRenderer($resultSet))->generate(); var_dump($array); // HTML table $tableRenderer = new HtmlTableRenderer($resultSet); echo $tableRenderer->generate(); // CSV header("Content-type: application/vnd.ms-excel"); header("Content-disposition: attachment; filename=\"export.csv\""); $csv = new CsvTableLayout($resultSet); print($csv->generate()); ``` Database exploration ---------------- ``` php findOneCube(null, array('CUBE_NAME' => 'Sales')); ?>, (*4)

getName() ?>, (*5)

  • Measures
      getMeasures() as $measure): ?>
    • getCaption() ?>
  • getDimensionsAndHierarchiesAndLevels() as $dimention): ?> getType() != 'MEASURE') : ?>
  • getCaption() ?>
      getHierarchies() as $hierarchy): ?>
    • getCaption() ?>
        getLevels() as $level): ?>
      • getCaption() ?>

```, (*6)

License

phpOLAPi is released under the MIT license., (*7)

The Versions

06/06 2018

dev-master

9999999-dev

A PHP API for XMLA to connect to OLAP databases

  Sources   Download

MIT

The Development Requires

by Julien Jacottet
by Andrej Kabachnik

06/06 2018

2.0.1

2.0.1.0

A PHP API for XMLA to connect to OLAP databases

  Sources   Download

MIT

The Development Requires

by Julien Jacottet
by Andrej Kabachnik

04/06 2018

2.0.0

2.0.0.0

A PHP API for XMLA to connect to OLAP databases

  Sources   Download

MIT

The Development Requires

by Julien Jacottet
by Andrej Kabachnik

15/09 2016

1.0.2

1.0.2.0

phpOlap is a php API for OLAP (XMLA)

  Sources   Download

MIT

The Requires

 

The Development Requires

by Julien Jacottet

30/08 2016

1.0.1

1.0.1.0

phpOlap is a php API for OLAP (XMLA)

  Sources   Download

MIT

The Requires

 

The Development Requires

by Julien Jacottet

29/12 2015

1.0

1.0.0.0

phpOlap is a php API for OLAP (XMLA)

  Sources   Download

MIT

The Requires

 

The Development Requires

by Julien Jacottet