Here is some code to tabulate questions in PHP

 

<?php
// url to test : http://[server]/[VirtualDirectory]/TOM.php?q=d1&m=&f=d1.containsany({japan,china})

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

if (isset($_GET["q"]) && $_GET["q"] != ""){
// d1*d3 or d1]d3 or d1+d3
$q = $_GET["q"]; 
$q = str_replace("]","+",$q); 
echo $q;
} else {
die("No Question Specified"); 
}

if (isset($_GET["m"]) && $_GET["m"] != ""){
$m = "json"; 
} else {
$m="html";
}

if (isset($_GET["f"]) && $_GET["f"] != ""){
$filter =$_GET["f"]; 
} else {
$filter="";
}

//phpinfo();
echo 'Start';
// Create the Tables object and open the DataSet
//Set TableDoc = CreateObject("TOM.Document")
$oTableDoc = new COM("TOM.Document") or die("Unable to instantiate TOM.Document"); 

$sProject = "CSUITE_2019";
$oMDD = "D:\\FMRoot\\Master\\CSUITE_2019\\CSUITE_2019.mdd";


$oData = "Provider=SQLOLEDB.1;Data Source=IBMIBV001;User ID=;Password=;Initial Catalog=" . $sProject . ";Integrated Security=SSPI;Persist Security Info=true";

$oTableDoc->DataSet->Load($oMDD, "", $oData, "mrRdbDsc2", "", "{..}");
$oTableDoc->DataSet->View = 1 ;

// Set the properties of the table document
//$oTableDoc->Language = "ENA";
//$oTableDoc->Context = "Question";
//$oTableDoc->LabelType = "Label";


$oTableDoc->Default->Clear();
$oTableDoc->Default->CellItems->AddNew(0);
//$oTableDoc->Default->CellItems->AddNew(1); // Percents
$oTableDoc->ProfileDefault->Clear();

//Define the tables
$oTable = $oTableDoc->Tables->AddNew("Table1",$q, "Table1");
if ( $filter != "" ) {
echo $filter;
$oTable->Filters->AddNew("Filter1", $filter);
}
//Table.Filters.AddNew("Filter1", "d1.ContainsAny({China})")

//Populate the tables
$oTableDoc->Populate();
$oTableXML = $oTableDoc->GetTablesXml("Table1", 1);

$xml=simplexml_load_string($oTableXML) or die("Error: Cannot create object");
$json = json_encode($xml); // convert the XML string to JSON

if ( $m == "json" ) {
echo $json;
} else {
$oHtmlRender = new COM("ExportHtml.Renderer") or die("Unable to instantiate TOM.Document"); 
//$oHtmlRender->OutputBodyOnly = 1;
echo $oHtmlRender->Render($oTableXML);
}

// Render as an HTML table
//$oHtmlRender = new COM("ExportHtml.Renderer") or die("Unable to instantiate TOM.Document"); 
//$oHtmlRender->OutputBodyOnly = 1;
//echo $oHtmlRender->Render($oTableXML);

echo 'Done';

?>

PHP to List mdd labels

Here is some code to list the variables in an MDD

 

<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

//phpinfo();
echo 'Start';
// Create the MDM object and open the Short Drinks .mdd file in read-write mode

$oMDM = new COM("MDM.Document") or die("Unable to instantiate MDM.Document"); 
$oMDM->Open("C:\\inetpub\\wwwroot\\IBV_USERS.mdd", '', 2);
foreach ($oMDM->Variables as $oVar) {
echo $oVar->Label ."<br/>";
}


echo 'Done';

?>