DataModule

From HTML5 Builder
Jump to: navigation, search

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:

  1. On the DataModule script, the one where you define the class:
    1. Define $application as a global variable: global $application;.
    2. Instantiate the class, that is, create an instance of it and assign it to a variable. For example: $dataModule = new DataModule($application);.
  2. On the main script:
    1. Place a requite_once() statement at the end of your includes for the DataModule script. For example: require_once(data.php);

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;
}

See Also