SQL and Database Infrastructure

Database Independent Abstraction Layer for C: libdbi Programmer's Guide
Prev | Chapter 3. libdbi API Reference | Next

# 3.4. SQL and Database Infrastructure

## 3.4.1. dbi_driver_connect

    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.

Arguments

  `Driver`: The target driver.

Returns

  -1 on failure, zero on success.

## 3.4.2. dbi_driver_get_db_list

    dbi_result dbi_driver_get_db_list(dbi_driver Driver)

Queries the list of available databases on the server.

Arguments

  `Driver`: The target driver.

Returns

  A query result object, which will contain a field named "dbname" from which the standard row/field fetching functions can be used.

## 3.4.3. dbi_driver_get_table_list

    dbi_result dbi_driver_get_table_list(dbi_driver Driver, const char *db)

Queries the list of available tables in a particular database.

Arguments

  `Driver`: The target driver.

  `db`: The target database name.

Returns

  A query result object, which will contain a field named "tablename" from which the standard row/field fetching functions can be used.

## 3.4.4. dbi_driver_query

    dbi_result dbi_driver_query(dbi_driver Driver, const char *formatstr, ...)

Execute the specified SQL query statement.

Arguments

  `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.

Returns

  A query result object, or NULL if there was an error.

## 3.4.5. dbi_driver_select_db

    int dbi_driver_select_db(dbi_driver Driver, const char *db)

Switches to a different database on the server.

Arguments

  `Driver`: The target driver.

  `db`: The target database name.

Returns

  -1 on failure, zero on success.

## 3.4.6. dbi_result_get_driver

    dbi_driver dbi_result_get_driver(dbi_result Result)

Returns the driver belonging to the specified result object.

Arguments

  `Result`: The target query result.

Returns

  The driver belonging to the target query result.

## 3.4.7. dbi_result_free

    int dbi_result_free(dbi_result Result)

Frees the result's query, disables all stored field bindings, and releases internally stored variables.

Arguments

  `Result`: The target query result.

Returns

  -1 on failure, zero on success.

## 3.4.8. dbi_result_seek_row

    int dbi_result_seek_row(dbi_result Result, unsigned int row)

Jump to a specific row in a result set.

Arguments

  `Result`: The target query result.

  `row`: The ordinal number of the row to seek to. The first row is at position 1, not zero.

Returns

  The row number that was fetched, or 0 if there is an error.

## 3.4.9. dbi_result_first_row

    int dbi_result_first_row(dbi_result Result)

Jump to the first row in a result set.

Arguments

  `Result`: The target query result.

Returns

  The row number that was fetched, or 0 if there is an error.

## 3.4.10. dbi_result_last_row

    int dbi_result_last_row(dbi_result Result)

Jump to the last row in a result set.

Arguments

  `Result`: The target query result.

Returns

  The row number that was fetched, or 0 if there is an error.

## 3.4.11. dbi_result_prev_row

    int dbi_result_prev_row(dbi_result Result)

Jump to the previous row in a result set.

Arguments

  `Result`: The target query result.

Returns

  The row number that was fetched, or 0 if there is an error.

## 3.4.12. dbi_result_next_row

    int dbi_result_next_row(dbi_result Result)

Jump to the next row in a result set.

Arguments

  `Result`: The target query result.

Returns

  The row number that was fetched, or 0 if there is an error.

## 3.4.13. dbi_result_get_numrows

    unsigned int dbi_result_get_numrows(dbi_result Result)

Returns the number of rows in the specified result set.

Arguments

  `Result`: The target query result.

Returns

  The number of rows in the result set.

## 3.4.14. dbi_result_get_numrows_affected

    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.

Arguments

  `Result`: The target query result.

Returns

  The number of modified rows in the result set.

Prev | Home | Next
Driver Infrastructure | Up | Retrieving field data