DataModule
DataModule is a container for invisible components used to store common reusable code, to later include it in several webpages.
Inclusion
To use a DataModule from a different script:
- On the DataModule script, the one where you define the class:
- Define
$application
as a global variable:global $application;
. - Instantiate the class, that is, create an instance of it and assign it to a variable. For example:
$dataModule = new DataModule($application);
.
- Define
- On the main script:
- Place a
requite_once()
statement at the end of your includes for the DataModule script. For example:require_once(data.php);
- Place a
Reference
To use the DataModule inside of any function, remember to define its variable as a global variable first, so a local variable is not used instead.
For example:
function ButtonClick($sender, $params) {
global $dataModule;
$this->DBGrid1->DataSource = $dataModule->DataSource;
}