Enumeration Type Documentation

For apr_dbd_p[v]query/select functions, in and out parameters are always const char * (i.e. regular nul terminated strings). LOB types are passed with four (4) arguments: payload, length, table and column, all as const char *, where table and column are reserved for future use by Oracle.

For apr_dbd_p[v]bquery/select functions, in and out parameters are described next to each enumeration constant and are generally native binary types or some APR data type. LOB types are passed with four (4) arguments: payload (char*), length (apr_size_t*), table (char*) and column (char*). Table and column are reserved for future use by Oracle.

PostgreSQL: the params is passed directly to the PQconnectdb() function (check PostgreSQL documentation for more details on the syntax).

SQLite2: the params is split on a colon, with the first part used as the filename and second part converted to an integer and used as file mode.

SQLite3: the params is passed directly to the sqlite3_open() function as a filename to be opened (check SQLite3 documentation for more details).

Oracle: the params can have "user", "pass", "dbname" and "server" keys, each followed by an equal sign and a value. Such key/value pairs can be delimited by space, CR, LF, tab, semicolon, vertical bar or comma.

MySQL: the params can have "host", "port", "user", "pass", "dbname", "sock", "flags" "fldsz", "group" and "reconnect" keys, each followed by an equal sign and a value. Such key/value pairs can be delimited by space, CR, LF, tab, semicolon, vertical bar or comma. For now, "flags" can only recognise CLIENT_FOUND_ROWS (check MySQL manual for details). The value associated with "fldsz" determines maximum amount of memory (in bytes) for each of the fields in the result set of prepared statements. By default, this value is 1 MB. The value associated with "group" determines which group from configuration file to use (see MYSQL_READ_DEFAULT_GROUP option of mysql_options() in MySQL manual). Reconnect is set to 1 by default (i.e. true).

FreeTDS: the params can have "username", "password", "appname", "dbname", "host", "charset", "lang" and "server" keys, each followed by an equal sign and a value.

- A label for the prepared statement. use NULL for temporary prepared statements (eg within a Request in httpd)

statement

- statement to prepare. May point to null on entry.

Returns:

0 for success or error code

Remarks:

To specify parameters of the prepared query, use %s, %d etc. (see below for full list) in place of database specific parameter syntax (e.g. for PostgreSQL, this would be $1, $2, for SQLite3 this would be ? etc.). For instance: "SELECT name FROM customers WHERE name=%s" would be a query that this function understands.

Here is the full list of format specifiers that this function understands and what they map to in SQL: %hhd (TINY INT), %hhu (UNSIGNED TINY INT), %hd (SHORT), %hu (UNSIGNED SHORT), %d (INT), %u (UNSIGNED INT), %ld (LONG), %lu (UNSIGNED LONG), %lld (LONG LONG), %llu (UNSIGNED LONG LONG), %f (FLOAT, REAL), %lf (DOUBLE PRECISION), %s (VARCHAR), %pDt (TEXT), %pDi (TIME), %pDd (DATE), %pDa (DATETIME), %pDs (TIMESTAMP), %pDz (TIMESTAMP WITH TIME ZONE), %pDb (BLOB), %pDc (CLOB) and %pDn (NULL). Not all databases have support for all these types, so the underlying driver will attempt the "best match" where possible. A % followed by any letter not in the above list will be interpreted as VARCHAR (i.e. %s).

Note that transaction modes, set by calling apr_dbd_transaction_mode_set(), will affect all query/select calls within a transaction. By default, any error in query/select during a transaction will cause the transaction to inherit the error code and any further query/select calls will fail immediately. Put transaction in "ignore
errors" mode to avoid that. Use "rollback" mode to do explicit rollback.