我使用olap4php连接到Mondrian的默认FoodMart XML架构,我需要在其上运行MDX查询以查看是否可以让它工作。
我目前的代码如下: -
require_once( 'olap4php/autoload.php' );
use OLAP4PHP\Provider\XMLA\XMLAConnection;
$endpoint = "http://server:8888/myproject/FoodMart.xml";
$properties = array(
XMLAConnection::PROP_CATALOG => 'FoodMart',
XMLAConnection::PROP_DATASOURCE => 'Provider=Mondrian;DataSource=FoodMart'
);
$connection = new XMLAConnection( $endpoint, $properties );
if ($connection) {
echo "yes";
}
输出为“是”,所以我相信连接正常。现在我想对它运行一个MDX查询,一些查询如
SELECT {[Measures].[Unit Sales], [Measures].[Store Sales]} ON COLUMNS,
{[Product].members} ON ROWS
FROM [Sales]
WHERE [Time].[1997].[Q2]
答案 0 :(得分:0)
Getting Started Guide表示将查询字符串放入$ query,然后:
use OLAP4PHP\Provider\XMLA\XMLAStatement;
$statement = new XMLAStatement( $connection );
$cellSet = $statement->executeOlapQuery( $query );