*

NAME dbd_register_driver
	PROTO void dbd_register_driver(const dbi_info_t **_driver_info, const char ***_custom_functions, const char ***_reserved_words)
	DESC
	This is the first function called after the driver module is loaded into memory. It passes back meta-information back to libdbi through the pointers passed as arguments.	
	ENDDESC
	ARG _driver_info A pointer used to link to the driver's information struct.
	ARG _custom_functions A pointer used to link to the driver's string array of custom database-specific functions.
	ARG _reserved_words A pointer used to link to the driver's string array of reserved words.
	RET 

*

NAME dbd_initialize
	PROTO int dbd_initialize(dbi_driver_t *driver)
	DESC
	Performs any database-specific server initialization. This is called right after dbd_register_driver().
	ENDDESC
	ARG driver The driver's pointer.
	RET -1 on error, 0 on success. If -1 is returned, the driver will not be added to the list of available drivers.

*

NAME dbd_connect
	PROTO int dbd_connect(dbi_conn_t *conn)
	DESC
	Connects to the database, setting the connection's DB-specific connection handle and current database name. Connection parameters are already filled through the connection's option settings. The standard options that all drivers must recognize (if applicable) are: host, username, password, dbname, and port. Any driver-specific functions must be prefixed with the name of the driver and an underscore, such as "mysql_compression".
	ENDDESC
	ARG conn The target connection instance of the driver.
	RET -1 on error, 0 on success.

*

NAME dbd_disconnect
	PROTO int dbd_disconnect(dbi_conn_t *conn)
	DESC
	Disconnects from the database server.
	ENDDESC
	ARG conn The target connection instance of the driver.
	RET -1 on error, 0 on success.

*

NAME dbd_fetch_row
	PROTO int dbd_fetch_row(dbi_result_t *result, unsigned int rownum)
	DESC
	Fetches the target row, retrieving one-time field information if necessary. Also see the _dbd_row_allocate and _dbd_row_finalize helper functions.
	ENDDESC
	ARG result The target result object.
	ARG rownum The row number to fetch.
	RET 0 on error, 1 on successful fetch.

*

NAME dbd_free_query
	PROTO int dbd_free_query(dbi_result_t *result)
	DESC
	Frees the target result handle.
	ENDDESC
	ARG result The target result handle.
	RET 0 on success (this should be changed)

*

NAME dbd_goto_row
	PROTO int dbd_goto_row(dbi_result_t *result, unsigned int row)
	DESC
	Jumps to the specifed row in the result set.
	ENDDESC
	ARG result The target result handle.
	ARG row The target row number.
	RET 1 on success, 0 on error.

*

NAME dbd_list_dbs
	PROTO dbi_result_t *dbd_list_dbs(dbi_conn_t *conn)
	DESC
	Performs a query that retrieves the list of databases, with the database name as the first column in the result set.
	ENDDESC
	ARG conn The target connection.
	RET A DBI result object.

*

NAME dbd_list_tables
	PROTO dbi_result_t *dbd_list_tables(dbi_conn_t *conn, const char *db)
	DESC
	Performs a query that retrieves the list of tables in the specified database, with the table name as the first column in the result set.
	ENDDESC
	ARG conn The target connection.
	ARG db The name of the database where tables should be looked for.
	RET A DBI result object.

*

NAME dbd_query
	PROTO dbi_result_t *dbd_query(dbi_conn_t *conn, const char *statement)
	DESC
	Performs a query and keeps track of meta-information about the query. Also see the _dbd_result_create helper function.
	ENDDESC
	ARG conn The target connection.
	ARG statement The query string to execute.
	RET A DBI result object, or NULL on error.

*

NAME dbd_quote_string
	PROTO int dbd_quote_string(dbi_driver_t *driver, const char *orig, char *dest)
	DESC
	Given a string, wrap quotes around that string and escape any characters that the database server needs escaped.
	ENDDESC
	ARG driver A pointer to the driver itself, which may be useful in weird cases.
	ARG orig The string to quote and escape.
	ARG dest The destination for the new string, which is already allocated as (strlen(orig)*2)+4+1. In the worst case, each character will need to be escaped, with two quote characters at both the beginning and end of the string, plus one for the terminating NULL.
	RET The length of the new string.

*

NAME dbd_select_db
	PROTO char *dbd_select_db(dbi_conn_t *conn, const char *db)
	DESC
	Selects a new database on the server.
	ENDDESC
	ARG conn The target connection.
	ARG db The name of the database to switch to.
	RET The database name on success, "" on error, or NULL if the operation is not supported by the database server.

*

NAME dbd_geterror
	PROTO int dbd_geterror(dbi_conn_t *conn, int *errno, char **errstr)
	DESC
	Retrieves and stores error information, in numeric and/or string format.
	ENDDESC
	ARG conn The target connection.
	ARG errno The int variable to hold the error number.
	ARG errstr The string to hold the error description.
	RET 0 if there was an error, 1 if errno was filled, 2 if errstr was filled, 3 if both errno and errstr were filled.

*

NAME _dbd_result_create
	PROTO dbi_result_t *_dbd_result_create(dbi_conn_t *conn, void *handle, unsigned int numrows_matched, unsigned int numrows_affected)
	DESC
	Allocates a new dbi_result_t, filling the number of rows matched and affected, storing the database-specific result handle, and allocating room for rows to be stored.
	ENDDESC
	ARG conn The target connection.
	ARG handle The database-specific result handle used internally by the driver.
	ARG numrows_matched The number of rows matched by the query.
	ARG numrows_affected The number of rows affected by the query.
	RET A new DBI result object.

*

NAME _dbd_result_set_numfields
	PROTO void _dbd_result_set_numfields(dbi_result_t *result, unsigned int numfields)
	DESC
	Sets a result's number of fields and allocates room for field information to be stored.
	ENDDESC
	ARG result The target result.
	ARG numfields The number of fields in the result set.
	RET 

*

NAME _dbd_result_add_field
	PROTO void _dbd_result_add_field(dbi_result_t *result, unsigned int idx, char *name, unsigned short type, unsigned int attribs)
	DESC
	Stores information about the target field into the result set.
	ENDDESC
	ARG result The target result.
	ARG idx The numeric field index.
	ARG name The name of the field.
	ARG type The datatype of the field.
	ARG attribs The attributes of the field.
	RET 

*

NAME _dbd_row_allocate
	PROTO dbi_row_t *_dbd_row_allocate(unsigned int numfields)
	DESC
	Allocates a new row, ready to be filled with data.
	ENDDESC
	ARG numfields The number of fields in the result set.
	RET A new DBI row, or NULL on error.

*

NAME _dbd_row_finalize
	PROTO void _dbd_row_finalize(dbi_result_t *result, dbi_row_t *row, unsigned int idx)
	DESC
	Associates and stores the row with the result set, once the row's data has been filled.
	ENDDESC
	ARG result The target result set.
	ARG row The target row object.
	ARG idx The index of the row.
	RET 

*

NAME _dbd_internal_error_handler
	PROTO void _dbd_internal_error_handler(dbi_conn_t *conn, const char *errmsg, const int errno)
	DESC
	Saves error message information generated by libdbi (rather than by the database or its API). If an old error message string exists, it will be freed.
	ENDDESC
	ARG conn The target connection.
	ARG errmsg The error message to store. This will be stdup'd by libdbi so it has its own copy.
	ARG errno The error number to store.
	RET 

