All functions within the driver have to be written according to a prototype. Below you'll find a list of prototypes to which the driver functions have to conform.
This functions provide the DAL with a function to select a database. The DAL will check if there is a connection to the database so that doesn't have to be done within this function. However, with postgres by example you have the case that the database will be selected at connect time. So this requires a special solution within the driver. The order as DAL will call the function is always connectDB -> selectDB. So with putting in special functions you can use that knowlegde.
Boolean selectDB
(string database);
This function executes the query. In other words this function feeds it to the database. The function doesn't need to perform error checking like is there a connection to the database. DAL is taking care of that. So if there is no commection to the database the query won't be feeded to this function.
int executeQuery
(String query);
This function connects to the database. Any needed variables can be taken from the global scope. This includes username+password and connectstring.
Int connectDB
(void);
This functions closes the database connection
boolean closeDB
(void);
This function returns an array with the capabilities of the driver.
array capabilities
(void);
This function returns the error, if any, that occured while processing the last instruction.
string getDBerror
(void);This function returns an object of the last result. It's returning one object per row. So if there are 10 rows this function can get called 10 times.
object fetchObject
(void);This function is called by the DAL to find out how many rows where affected by an insert, update or delete statement.
int affectedRows
(void);This functions is called by the DAL to find out how many rows there are in the resultset. So basicly it's finding out how many rows where returned by a select.
int resultRowcount
(void);This function returns a row as an associative array (array is indexed by fieldnames from the database)
array fetchArray
(void);This function returns a row as an indexed array.
array fetchRow
(void);This function returns the last inserted record. This record is the last one that got inserted via the object from which this function is called. This implies that checking for the last insert should be done at an insert query.
object fetchLastInsert
(void);This functions starts a transaction. The checking for any running transactions is done by DAL. So the only thing to do is to actually start the transaction. Returns true on success and false on failure.
boolean
startTransaction
(void);Commits a running transaction. The check if there is a running transaction will be done by DAL. So the only concern is to commit the transaction to the database. Returns true on success and false on failure.
boolean
commitTransaction
(void);Aborts a running transaction. The check if there is a running transaction is done by DAL. Returns true on success and false on failure.
boolean
abortTransaction
(void);This functions seeks to the next record if possible. Returns true on success and false on failure.
boolean
nextRecord
(void);This functions seeks to the previous record if possible. Returns true on success and false on failure.
boolean
prevRecord
(void);This function takes an integer as argument and seeks to that row number. Returns true on success and false on failure.
boolean
prevRecord
( int
rowID
);This function saves the current state of the driver. So the database connection, the current resultset and so on. This function needs to be completed successfully and therefore doesn't return anything. Al the important things within the driver need to get saved with this function.
saveState
(void);This function restores the saved state. It also destroys any resultsets created after the saved state. So basicly it makes sure that everything that has happened after the saveState doesn't leave any traces.
restoreState
(void);