NOTE: Flexmonster Data Compressor is considered deprecated, so the approach described below is not recommended for connecting to SQL databases.
To see the relevant way of connecting to relational databases, refer to this article.
If Flexmonster is not yet embedded, set up an empty component in your webpage:
Complete the Integrating Flexmonster guide. Your code should look similar to the following example:
Add the following dependency to your project: flexmonster-compressor.php
. It is located in the Pivot Table for Databases/server/php/
folder of the download package:
Below is a connection and query sample for a MySQL database:
Then the following line of code will start streaming a $result
:
The full project is available at Pivot Table for Databases/server/php/
inside the download package.
By default, the browser prevents JavaScript from making requests across domain boundaries. CORS allows web applications to make cross-domain requests. Here are some useful links explaining how to setup CORS on your server:
Alternatively, you can add the following headers at the beginning of PHP file:
Now it’s time to configure the pivot table on the webpage. Let’s create a minimal report for this (replace filename
and other parameters with your specific values):
Launch the webpage from a browser — there you go! A pivot table is embedded into your project. Check out the example on JSFiddle.
Here you can find a few PHP examples of compressing different databases.
It is likely that output_buffering
is enabled in the PHP configuration on your server and therefore data is not streaming. Try disabling it in php.ini
for better performance:output_buffering = Off
(see https://php.net/manual/en/outcontrol.configuration.php).
You may be interested in the following articles: