mod_sql is a provider for the Apache XML Namespace API that harness the Apache DBD Framework to enable SQL queries (and results) to be embedded into XML applications via a namespace. It will typically be used together with mod_form or similar processor to provide a complete and ultra-fast environment for Forms handling with an SQL backend.
mod_sql implements a namespace for accessing databases from an HTML or XML page. This relies on mod_publisher or mod_xmlns, and requires at least one database driver.
The namespace http://apache.webthing.com/sql# implements
the following elements. Most of the complex attributes such as
(format
, errfmt
, query
),
can be Environment variables (e.g. set in httpd.conf or an
SSI set
directive), or can be Form variables if mod_form is available.
Documentation to follow.
mod_sql is currently experimental. Use at your own risk, and please report problems/bugs.
<sql:dbd driver="foo" version="bar"
errmsg="connection to foo failed" dbname="somedb"
output="html">
driver
/ version
.
Selects dbname
if the driver supports set_dbname,
and sets a format for any output generated. If the operation fails, it
logs an error, and returns the errmsg
to the client if
and only if one is set. The lifetime of the connection is until the
closing </sql:dbd>
.<sql:error format="<p>Error from foo: %s</p>"/>
<sql:query query="some SQL statement" errfmt="foobar" />
errfmt
if supplied overrides the current <sql:error ...
>
setting.<sql:results ....>
select
,
depending on the output
attribute to sql:dtd
.
Attributes depend on the output
; currently only HTML
is supported and this is a no-op for other types.<sql:select query="some SQL statement"
format="<tr><td>%0;</td><td>%2;</td></tr>"
errfmt="some other errfmt: %s" />
errfmt
if supplied overrides the current <sql:error ...
>
setting.<sql:transaction>
sql:transaction
is closed, it will either
be committed or rolled back, depending on whether an error occurred
within the transaction. If a driver doesn't support transactions,
this is a no-op.The above API is expected to grow in due course to support more advanced database usage.
mod_sql.c is available under the GNU General Public License (GPL). As with other opensource modules, we can consider alternative licenses by request.