Database Query Functions

Database Independent Abstraction Layer for C: libdbi Driver Author's Guide (OUTDATED SEE README!)
Prev | Chapter 2. Driver Functions | Next

# 2.2. Database Query Functions

## 2.2.1. dbd_fetch_row

    int dbd_fetch_row(dbi_result_t *result, unsigned int rownum)

Fetches the target row, retrieving one-time field information if necessary. Also see the _dbd_row_allocate and _dbd_row_finalize helper functions.

Arguments

  `result`: The target result object.

  `rownum`: The row number to fetch.

Returns

  0 on error, 1 on successful fetch.

## 2.2.2. dbd_free_query

    int dbd_free_query(dbi_result_t *result)

Frees the target result handle.

Arguments

  `result`: The target result handle.

Returns

  0 on success (this should be changed)

## 2.2.3. dbd_goto_row

    int dbd_goto_row(dbi_result_t *result, unsigned int row)

Jumps to the specifed row in the result set.

Arguments

  `result`: The target result handle.

  `row`: The target row number.

Returns

  1 on success, 0 on error.

## 2.2.4. dbd_list_dbs

    dbi_result_t *dbd_list_dbs(dbi_conn_t *conn)

Performs a query that retrieves the list of databases, with the database name as the first column in the result set.

Arguments

  `conn`: The target connection.

Returns

  A DBI result object.

## 2.2.5. dbd_list_tables

    dbi_result_t *dbd_list_tables(dbi_conn_t *conn, const char *db)

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.

Arguments

  `conn`: The target connection.

  `db`: The name of the database where tables should be looked for.

Returns

  A DBI result object.

## 2.2.6. dbd_query

    dbi_result_t *dbd_query(dbi_conn_t *conn, const char *statement)

Performs a query and keeps track of meta-information about the query. Also see the _dbd_result_create helper function.

Arguments

  `conn`: The target connection.

  `statement`: The query string to execute.

Returns

  A DBI result object, or NULL on error.

## 2.2.7. dbd_select_db

    char *dbd_select_db(dbi_conn_t *conn, const char *db)

Selects a new database on the server.

Arguments

  `conn`: The target connection.

  `db`: The name of the database to switch to.

Returns

  The database name on success, "" on error, or NULL if the operation is not supported by the database server.

Prev | Home | Next
Driver Infrastructure Functions | Up | DBD Helper Functions