Chapter 2. Using DAL

Table of Contents
The config file
The basics
Fetching results
Seeking through results
Errorhandling
Transaction support
Configuration Management
Miscellaneous functions
Example of using DAL

DAL is set up in a way that it provides a transparant layer to the database. So when you want to use DAL in you project all database transactions should run via DAL. This way it makes it easy to use a different DBMS because the funtions of DAL stay the same no matter which DBMS you are using. The only thing you'll have to do is edit the config file and select a different driver in your code.

In this chapter i try to give you the information you'll need when you want to use DAL.

The config file

DAL get's configured by a configuration object. This object contains some variables which configure DAL. Below you'll find a list of those variables and the meaning of them.

$basedir

This is the basedir where DAL is located. The extension dir, drivers dir, and so on are all derived from the basedir.

$drivers

Contains an array of drivers which can be selected.

$configurations

Contains an array of arrays which contain the configuration info for a connection to the DBMS. The array with info contains 3 variables:

  • dbuser (username to use)

  • dbpassword (password for the username)

  • dbconnectString (string which can provide extra parameters)

$configurationLocked

Is it allowed to add new configuration parameters via the script after the configuration file is loaded.

$extensionDir

Which dir do we use for extensions

$extensionUseHooks

Are extensions allowed to use hooks

$fullExtensionDir

Variable which is used by the configuration object itself to assemble a full extension directory

$language

Which language to use. Current choices are:

  • english

  • portugues

  • dutch

$fileExt

Specifies which extension the classes loaded by DAL have. It controles the extension the driver files have and the main class of extensions that can be loaded in. So if you set it by example to ".inc" everything in the drivers dir has .inc as file extension. For an extension called debugger (which main class is class_debugger) the file extension will also be .inc, any classes loaded by the extension are beyond the scope of $fileExt. Also the file extension of class_extensionObject will be .inc because that's also loaded in by DAL.

So summarized the file extension of the following files will be controlled by $fileExt:

  • drivers/*

  • $extensionDir/$extension/class_$extension

  • class_extensionObject