SYNOPSIS

\*(T<#include <opendbx/api.h>\*(T>

\*(T<int odbx_bind\*(T> \kx \*(T<(odbx_t* handle, const char* database, const char* who, const char* cred, int method);\*(T>

\*(T<int odbx_bind_simple\*(T> \kx \*(T<(odbx_t* handle, const char* database, const char* who, const char* cred);\*(T>

DESCRIPTION

\*(T<odbx_bind\*(T>() associates a connection created by \*(T<odbx_init\*(T>() to a specific database after the server verified and accepted the user credentials. All further operations will (normally) only affect the tables and records within this database. The operations may be limited to certain subset depending on the privileges granted to the given user account. If binding to the database instance succeeded, \*(T<odbx_bind\*(T>() also enables compatibility to the ANSI SQL standard if this is possible for the database server implementation.

\*(T<odbx_bind_simple\*(T>() performs the same tasks as \*(T<odbx_bind\*(T>() but can't do anything else than simple user name / password authentication. It shouldn't be used in applications linking to the OpenDBX library version 1.1.1 or later and it will be removed from the library at a later stage.

Both functions accept almost the same parameters. The \*(T<handle\*(T> parameter always has to be a pointer to a valid connection object allocated by \*(T<odbx_init\*(T>(). The availability of certain options or the behavior of the connection associated to the given odbx_t pointer can be queried by calling \*(T<odbx_get_option\*(T>() respectively changed by \*(T<odbx_set_option\*(T>(). Changes must be done before calling \*(T<odbx_bind\*(T>() to take any effect. Examples of options are the thread-safetiness of the native database client library or the support for sending multiple statements at once.

\*(T<database\*(T> is necessary to let the database server know which database should be used for executing all further requests. In combination with the authentication parameters \*(T<who\*(T> and \*(T<cred\*(T>, it usually allows or denies operations on tables and records within this database. Contrary to that, SQLite doesn't use \*(T<who\*(T> and \*(T<cred\*(T> but relies on the file system permissions instead to grant access to the whole database file. If they are used, the supplied values for all three parameters must be zero-terminated strings and should be in exactly the same character case as stored by the database manager. Otherwise, if they are unused they can also be NULL. Some database libraries also support default values provided by a configuration file if a parameter is NULL.

\*(T<method\*(T> specifies the mechanism for authenticating a user account before it can perform operations on tables and records. Currently, all database backend modules only support the \*(T<ODBX_BIND_SIMPLE\*(T> method which provides basic user name / password authentication. In this case, the parameter \*(T<who\*(T> must be the name of an user account while \*(T<cred\*(T> has to be the password that belongs to the given account.

An already associated connection object can be detached from the database and rebound to the same database server. It is possible to bind it to another database, with another user account and other options set by detaching the connection object with \*(T<odbx_unbind\*(T>() first before invoking \*(T<odbx_bind\*(T>() with the same or with different parameters again.

RETURN VALUE

\*(T<odbx_init\*(T>() returns \*(T<ODBX_ERR_SUCCESS\*(T>, or an error code whose value is less than zero if one of the operations couldn't be completed successfully. Possible error codes are listed in the error section and they can be feed to \*(T<odbx_error\*(T>() and \*(T<odbx_error_type\*(T>() to get further details.

ERRORS

-\*(T<ODBX_ERR_BACKEND\*(T>

The backend module returned an error because it couldn't connect to the database or the authentication using the supplied parameters failed

-\*(T<ODBX_ERR_PARAM\*(T>

One of the supplied parameters is invalid or is NULL and this isn't allowed in the used backend module or in the native database client library

-\*(T<ODBX_ERR_NOMEM\*(T>

Allocating additionally required memory failed

-\*(T<ODBX_ERR_SIZE\*(T>

The length of a string exceeded the available buffer size

-\*(T<ODBX_ERR_NOTSUP\*(T>

The supplied authentication method is not supported by the backend module

RELATED TO odbx_bind…

\*(T<odbx_error\*(T>(), \*(T<odbx_error_type\*(T>(), \*(T<odbx_init\*(T>(), \*(T<odbx_query\*(T>(), \*(T<odbx_unbind\*(T>()