Database Independent Abstraction Layer for C: libdbi Programmer's Guide | ||
---|---|---|
Prev | Chapter 2. libdbi in a Nutshell (Quickstart Guide) | Next |
The generic example shown in the previous section assumed that the program is linked against libdbi. This is in fact the recommended way to add libdbi functionality to your programs. However, there are situations where this approach will not work. Some programs are designed to load modules at runtime to extend their capabilities. A well-known example is the web server Apache, which uses loadable modules to custom-tailor its capabilities. If such a module were to use libdbi, we'd look at the following pattern:
Both libdbi and the drivers have to be loaded using the dl_open
function as it is not possible to link the dynamically loaded module against libdbi. For this pattern to work, the drivers need a little tweak, like this:
~/libdbi-drivers #./configure --enable-libdbi --with-mysql |
Drivers built with this option are supposed to work both with the procedure shown above and with the generic procedure shown in the previous section. This has been tested on Linux, FreeBSD, and Cygwin. You may want to test the drivers on other platforms in both modes to avoid surprises.