Database Independent Abstraction Layer for C: libdbi Programmer's Guide | ||
---|---|---|
Prev | Chapter 3. libdbi API Reference | Next |
int dbi_driver_connect(dbi_driver Driver) |
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 plugin for the options it recognizes and requires.
Driver: The target driver.
-1 on failure, zero on success.
dbi_result dbi_driver_get_db_list(dbi_driver Driver) |
Queries the list of available databases on the server.
Driver: The target driver.
A query result object, which will contain a field named "dbname" from which the standard row/field fetching functions can be used.
dbi_result dbi_driver_get_table_list(dbi_driver Driver, const char *db) |
Queries the list of available tables in a particular database.
Driver: The target driver.
db: The target database name.
A query result object, which will contain a field named "tablename" from which the standard row/field fetching functions can be used.
dbi_result dbi_driver_query(dbi_driver Driver, const char *formatstr, ...) |
Execute the specified SQL query statement.
Driver: The target driver.
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.
int dbi_driver_select_db(dbi_driver Driver, const char *db) |
Switches to a different database on the server.
Driver: The target driver.
db: The target database name.
-1 on failure, zero on success.
dbi_driver dbi_result_get_driver(dbi_result Result) |
Returns the driver belonging to the specified result object.
Result: The target query result.
The driver 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 plugin for details.
Result: The target query result.
The number of modified rows in the result set.