With this method the database information file will contain the necessary information for the graphng software to connect to your database and the queries to run for each data series. At runtime the graphing software will read this file, connect to the database and execute each of the queries. It will then automatically extract the data from the result set(s) for plotting on the graph.
The database information file is a PHP script which assigns various options to a PHP array '$jpDatabase'. This file is used by the graphing software to connect to the database and execute the queries.
The array contains three sections of information:-
An example file can be found in the Sample Application directory ./jpowered/sampleApplication/dataQueries/dbConfig.php
To tell the graph to use a database information file the 'data' parameter of the IMG tag should be replaced with 'dbinfo' parameter, like this:-
The [RELATIVEpathTOdbinfoFILE] should be a relative filesystem file path to the database information file. This file path is relative to the location of the graph software and NOT the page which contains the IMG tag.
Database Connection Information
This section contains 4 parameters which provide the graphing software with the necessary information to open a connection to the database. The parameters are:-
Data Queries
The data query section contains the SQL the graph should issue to the database server to extract the data to be plotted. For each series of data
the graph needs to know:-
NOTE: All PHP Global variables ($_REQUEST, $_GET, $_POST, $_SESSION etc) are available to be used within the database information file. For instance if
you wish to dynamically construct a query based on the value of "userID" held in the session then you could do something like this:-
Database Abstraction Code
This parameter tells the graphing software to use database access methods located in the file specified.
The software will look for the file in the dir ./jpowered/graph/common/
Currently database methods are supplied for the MySQL database system and are located in the DBMySQL.class.php file. As such the
parameter should be set like this:-
Putting it all together the database information file should look like this:-