Database Independent Abstraction Layer for C: libdbi Programmer's Guide (OUTDATED SEE README!) | ||
---|---|---|
Prev | Chapter 3. libdbi API Reference | Next |
int dbi_conn_connect(dbi_conn Conn) |
Connects to the database using the options (host, username, password, port, (etc.) set with dbi_set_option() and dbi_set_option_numeric(). See the documentation for each specific database driver for the options it recognizes and requires.
Conn: The target connection.
-1 on failure, zero on success.
dbi_result dbi_conn_get_db_list(dbi_conn Conn, const char *pattern) |
Queries the list of available databases on the server.
Conn: The target connection.
pattern: A string pattern that each name must match.
A query result object, which will contain database names in the first (zeroth) field (for use with the by-index field functions).
dbi_result dbi_conn_get_table_list(dbi_conn Conn, const char *db, const char *pattern) |
Queries the list of available tables in a particular database.
Conn: The target connection.
db: The target database name.
pattern: A string pattern that each name must match.
A query result object, which will contain table names in the first (zeroth) field (for use with the by-index field functions).
dbi_result dbi_conn_query(dbi_conn Conn, const char *formatstr, ...) |
Execute the specified SQL query statement.
Conn: The target connection.
formatstr: The format string for the SQL statement. It uses the same format as printf().
ARG: (...) Any variables that correspond to the printf-like format string.
A query result object, or NULL if there was an error.
dbi_result dbi_conn_query_null(dbi_conn Conn, const unsigned char *statement, unsigned long st_length) |
Execute the specified SQL query statement, which may contain valid NULL characters.
Conn: The target connection.
statement: The SQL statement, which may contain binary data.
st_length: The number of characters in the non-null-terminated statement string.
A query result object, or NULL if there was an error.
int dbi_conn_select_db(dbi_conn Conn, const char *db) |
Switches to a different database on the server.
Conn: The target connection.
db: The target database name.
-1 on failure, zero on success.
dbi_conn dbi_result_get_conn(dbi_result Result) |
Returns the connection belonging to the specified result object.
Result: The target query result.
The connection belonging to the target query result.
int dbi_result_free(dbi_result Result) |
Frees the result's query, disables all stored field bindings, and releases internally stored variables.
Result: The target query result.
-1 on failure, zero on success.
int dbi_result_seek_row(dbi_result Result, unsigned int row) |
Jump to a specific row in a result set.
Result: The target query result.
row: The ordinal number of the row to seek to. The first row is at position 1, not zero.
The row number that was fetched, or 0 if there is an error.
int dbi_result_first_row(dbi_result Result) |
Jump to the first row in a result set.
Result: The target query result.
The row number that was fetched, or 0 if there is an error.
int dbi_result_last_row(dbi_result Result) |
Jump to the last row in a result set.
Result: The target query result.
The row number that was fetched, or 0 if there is an error.
int dbi_result_prev_row(dbi_result Result) |
Jump to the previous row in a result set.
Result: The target query result.
The row number that was fetched, or 0 if there is an error.
int dbi_result_next_row(dbi_result Result) |
Jump to the next row in a result set.
Result: The target query result.
The row number that was fetched, or 0 if there is an error.
unsigned int dbi_result_get_numrows(dbi_result Result) |
Returns the number of rows in the specified result set.
Result: The target query result.
The number of rows in the result set.
unsigned int dbi_result_get_numrows_affected(dbi_result Result) |
Returns the number of rows in the specified result set that were actually modified. Note that not all database servers support this, in which case it will always be zero. See the documentation for each specific driver for details.
Result: The target query result.
The number of modified rows in the result set.