2012-09-12 54 views
0

我使用olap4php連接到Mondrian的默認FoodMart XML模式,並且需要在其上運行MDX查詢以查看我是否可以使其工作。使用olap4php在PHP中使用PHP在Mondrian Cube上運行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

一些查詢的Getting Started Guide說你的查詢字符串放到$查詢,然後:

use OLAP4PHP\Provider\XMLA\XMLAStatement; 

$statement = new XMLAStatement($connection); 
$cellSet = $statement->executeOlapQuery($query);