Despite the COVID-19 outbreak, our team continues operating at full speed. We are always here to support and answer all your questions.

Feel free to reach out by filling this quick form.

Fill the form
Get Free Trial

Getting Flexmonster Pivot Table Connected to Traditional Databases

PLEASE NOTE: As soon as we update the Component with new features every new week the information might be outdated, please check our latest news.

FlexMonster Pivot Table Component can connect traditional databases like MS SQL, MySQL, Oracle, PostgreSQL and others very similarly as it can get connected to OLAP servers. The main underlying concept is using a simple script in PHP, C# or practically any platform that would connect database, load the data and pass it to Pivot Table as CSV.

Connect OLAP data to Pivot Table

Assuming that the component is already deployed at final location (see, Documentation: Embed Pivot into the Web Application), to connect Flexmonster Pivot to database, you need to prepare a script that should

  1. Let Pivot know where it has to take the data.
  2. Load the table from database with script.
  3. Convert it to CSV and simply return in response.

Let’s have a look at this simple PHP script. It connects to a MySQL database and returns a CSV that can be loaded in OLAP-like manner into Pivot.

// Replace with own credentials
mysql_select_db($database) or die( "Unable to select database");
$csv_output = "";
$table = "SampleTable";

function getCSVColumns() {
  global $table, $csv_output;
  $sql = "SHOW COLUMNS FROM ".$table;
  $result = mysql_query($sql);
  while ($row = mysql_fetch_assoc($result)) {
    $csv_output .= $row["Field"].",";
  $csv_output = substr($csv_output, 0, -1);
  $csv_output .= "\r\n";

function getCSVDataRows() {
  global $table, $csv_output;
  $query="SELECT * FROM ".$table;
  $result = mysql_query($query);
  while($row = mysql_fetch_row($result)){
    for ($i = 0; $i 

If you have an existing solution which Pivot has to be integrated, you can modify its routines to return CSV from existing configured DB sources.

You are welcome to modify the above sample or use it as a guideline to write a script for your particular platform.

See also these useful links in our reference manual: