DAL is easy in use. Once you configured it with the config file you don't have to worry about creating the connection or specifying usernames and so on. The only thing you have to do is tell DAL which driver you want to use. After that you can use DAL for executing you're queries, getting the results, showing error messages, etc.
The first thing we have to do is selecting a driver. This tells DAL which driver has to be loaded and how the queries have to be executed. Drivers can differ in capabillities. So with one driver loaded it's possible to have more functions than with loading another driver. If you try to access functions which the driver doesn't support the function will fail. DAL will set his errormessage to inform you that the capabillity that you're trying to access doesn't exist within the selected driver.
So selecting the driver to use is the first thing we have to do. But how ? Simply by calling selectDriver with as parameter the name of the driver we want to use. The function definition looks like this:
boolean selectDriver
(string driverName);
After you selected a driver the next thing to do is selecting the database which you want to use. On this database the queries will be executed.
You always have to select a database before you start executing queries. I think this seems very logical. If for some reason the selecting of the database fails DAL will return false and set his error message to the reason why selecting the datbase didn't work. The function definition looks like this:
boolean selectDatabase
(string database);
After you have told DAL which driver to use and selected the database on which you want to execute the queries you can go executing them.
Executing a query is fairly simple. You just provide dal with the sql query. DAL makes sure that everything is right (a database connection exists, a database is selected, etc) and executes the query. When executing the query was succesfull DAL will give you a boolean 'true'. If anything goes wrong or some conditions aren't met DAL wil return 'false' and sets the appropiate errormessage.
The function looks like this:
boolean executeQuery
(string query);
Aliases: q