Database Independent Abstraction Layer for C: libdbi Driver Author's Guide | ||
---|---|---|
Prev | Chapter 3. Driver Functions | Next |
Returns the character encoding used by the current connection.
conn: The target connection.
A zero-terminated string containing the IANA name of the character encoding.
Converts the database-engine-specific name of a character encoding to the corresponging IANA name.
db_encoding: A pointer to a string containing the character encoding name.
A zero-terminated string containing the IANA name of the character encoding. If there is no equivalent IANA name, the original string will be returned.
Converts the IANA name of a character encoding to the corresponging database-engine-specific name.
iana_encoding: A pointer to a string containing the character encoding name.
A zero-terminated string containing the database-engine-specific name of the character encoding. If there is no equivalent IANA name, the original string will be returned.
Returns the version string of the database engine that serves the current connection.
conn: The current connection.
versionstring: A pointer to a string that can hold at least VERSIONSTRING_LENGTH bytes, including the trailing NULL byte. The function will write the version string to this buffer.
versionstring
which now contains a zero-terminated string representing the database engine version. This string contains only digits and periods. Returns an empty string in case of an error.
Performs a query that retrieves the list of databases, with the database name as the first column in the result set. If pattern
is non-NULL, only databases whose name match pattern
are listed.
conn: The target connection.
pattern: A SQL regular expression that limits the search, or NULL to list all tables.
A DBI result object, or NULL if an error occurs.
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. If pattern
is non-NULL, lists only the tables that match pattern
.
conn: The target connection.
db: The name of the database where tables should be looked for.
pattern: A SQL regular expression that limits the search, or NULL to list all tables.
A DBI result object, or NULL if an error occurs.
Given a string, wrap quotes around that string and escape any characters that the database server needs escaped.
Note: The use of this function in user programs is deprecated, but drivers must still implement it at the moment. If the quoting and escaping does not depend on the connection parameters, it is perfectly legal to let your implementation of dbd_conn_quote_string call this function (it is not possible to do it the other way). libdbi makes sure that both
orig
anddest
are non-NULL before calling this function.
driver: A pointer to the driver itself, which may be useful in weird cases.
orig: The string to quote and escape.
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.
The length of the new string.
Given a string, wrap quotes around that string and escape any characters that the database server needs escaped.
Note: The use of this function in user programs is preferred over dbd_quote_string. If the quoting and escaping does not depend on the connection parameters, it is perfectly legal to let your implementation of this function call dbd_quote_string. libdbi makes sure that both
orig
anddest
are non-NULL before calling this function.
conn: A pointer to the current connection.
orig: The string to quote and escape.
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.
The length of the new string.
Given a binary string (which may contain NULL bytes and other non-printable characters), wrap quotes around that string and escape any characters that the database server needs escaped. If the function returns an error, *dest
is not a valid pointer to a string.
conn: A pointer to the current connection.
orig: The string to quote and escape.
from_length: The length, in bytes, of the binary string.
dest: A pointer to the destination of the new zero-terminated string. The function allocates the required memory as required and updates the pointer that dest
points to accordingly.
The length of the new string, or DBI_LENGTH_ERROR in case of an error.
Performs a query and keeps track of meta-information about the query. Also see the _dbd_result_create helper function.
conn: The target connection.
statement: The zero-terminated query string to execute.
A DBI result object, or NULL on error.
Performs a query using a binary query string and keeps track of meta-information about the query. Also see the _dbd_result_create helper function.
conn: The target connection.
statement: The query string to execute, which may contain NULL bytes and other non-printable characters.
st_length: The length of the binary query string.
A DBI result object, or NULL on error.
Selects a new database on the server.
conn: The target connection.
db: The name of the database to switch to.
The database name on success, NULL on error, or an empty string if the operation is not supported by the database server.
Returns the row ID generated by the last INSERT command.
conn: The target connection.
sequence: The name of the sequence if the database engine requires this, or NULL if it is not required.
The row ID if successful, otherwise 0.
Increments the sequence counter by the preset increment, and returns the resulting row ID.
conn: The target connection.
sequence: The name of the sequence if the database engine requires this, or NULL if it is not required.
The row ID if successful, otherwise 0. Also return 0 if the database engine does not implement this feature.
Checks whether the database connection is still alive.
conn: The target connection.
1 if the connection is alive, otherwise 0. This function may be implemented such that it automatically attempts to reconnect if the connection went down. If the reconnect is successful, the function should also return 1.