Database Independent Abstraction Layer for C: libdbi Programmer's Guide (OUTDATED SEE README!) | ||
---|---|---|
Prev | Chapter 3. libdbi API Reference | Next |
unsigned int dbi_result_get_field_size(dbi_result Result, const char *fieldname) |
Returns the size in bytes of the value stored in the specified field. This is especially useful for string and binary data fields, which may have a dynamic size.
Result: The target query result.
fieldname: The name of the target field.
The size in bytes of the target field data.
unsigned int dbi_result_get_field_size_idx(dbi_result Result, unsigned int idx) |
Returns the size in bytes of the value stored in the specified field. This is especially useful for string and binary data fields, which may have a dynamic size.
Result: The target query result.
idx: The index of the target field (starting at 1).
The size in bytes of the target field data.
unsigned int dbi_result_get_field_length(dbi_result Result, const char *fieldname) |
Returns the length in bytes of the value stored in the specified field. This is always one less than the size, and is probably only useful for fields containing strings.
Result: The target query result.
fieldname: The name of the target field.
The length in bytes of the target field data.
unsigned int dbi_result_get_field_length_idx(dbi_result Result, unsigned int idx) |
Returns the length in bytes of the value stored in the specified field. This is always one less than the size, and is probably only useful for fields containing strings.
Result: The target query result.
idx: The index of the target field (starting at 1).
The length in bytes of the target field data.
int dbi_result_get_field_idx(dbi_result Result, const char *fieldname) |
Given a field's name, return that field's numeric index.
Result: The target query result.
fieldname: The name of the target field.
The index (starting at 1) of the target field.
const char *dbi_result_get_field_name(dbi_result Result, unsigned int idx) |
Given a field's numeric index, return that field's name.
Result: The target query result.
idx: The index of the target field (starting at 1).
The target field's name.
unsigned int dbi_result_get_numfields(dbi_result Result) |
Returns the number of fields in the query result.
Result: The target query result.
The number of fields in the query result.
unsigned short dbi_result_get_field_type(dbi_result Result, const char *fieldname) |
Returns the target field's data type. The constants returned by this function are defined in dbi.h with the prefix "DBI_TYPE_".
Result: The target query result.
fieldname: The target field's name.
The target field's data type.
unsigned short dbi_result_get_field_type_idx(dbi_result Result, unsigned int idx) |
Returns the target field's data type. The constants returned by this function are defined in dbi.h with the prefix "DBI_TYPE_".
Result: The target query result.
idx: The index of the target field (starting at 1).
The target field's data type.
unsigned long dbi_result_get_field_attrib(dbi_result Result, const char *fieldname, unsigned long attribmin, unsigned long attribmax) |
Returns the target field's data type attributes in the specified range. The constants returned by this function are defined in dbi.h with the prefix "DBI_", followed by the name of the field's datatype.
Result: The target query result.
fieldname: The target field's name.
attribmin: The first attribute value in the range of attributes to extract.
attribmax: The last attribute value in the range of attributes to extract. This may be the same as attribmin if you are only trying to extract a single attribute value.
The target field's requested attribute range.
unsigned long dbi_result_get_field_attrib_idx(dbi_result Result, unsigned int idx, unsigned long attribmin, unsigned long attribmax) |
Returns the target field's data type attributes in the specified range. The constants returned by this function are defined in dbi.h with the prefix "DBI_", followed by the name of the field's datatype.
Result: The target query result.
idx: The index of the target field (starting at 1).
attribmin: The first attribute value in the range of attributes to extract.
attribmax: The last attribute value in the range of attributes to extract. This may be the same as attribmin if you are only trying to extract a single attribute value.
The target field's requested attribute range.
unsigned long dbi_result_get_field_attribs(dbi_result Result, const char *fieldname) |
Returns the target field's data type attributes. The constants returned by this function are defined in dbi.h with the prefix "DBI_", followed by the name of the field's datatype.
Result: The target query result.
fieldname: The target field's name.
The target field's attributes.
unsigned long dbi_result_get_field_attribs_idx(dbi_result Result, unsigned int idx) |
Returns the target field's data type attributes. The constants returned by this function are defined in dbi.h with the prefix "DBI_", followed by the name of the field's datatype.
Result: The target query result.
idx: The index of the target field (starting at 1).
The target field's attributes.
int dbi_result_get_fields(dbi_result Result, const char *format, ...) |
Fetch multiple fields from the current result set, using a printf-like syntax. The formatter string specified field names and types, and each field's associated destination variable is passed as an argument following the format string. Fields in the formatter string are separated by spaces, and follow the format "a.%b", where "a" is the name of the field, and "b" is the field type specifier. Make sure you pass the destination variables' memory addresses by prepending the & operator to each variable's name.
Field type specifiers:
%c / %uc: A signed/unsigned character
%h / %uh: A signed/unsigned short integer
%l / %ul: A signed/unsigned long integer
%i / %ui: A signed/unsigned long integer
%L / %uL: A signed/unsigned long long integer
%f: A floating point number
%d: A double-precision number
%s: A read-only string
%S: A local copy of a string (must be freed by program)
%b: A read-only pointer to binary data
%B: A local copy of binary data (must be freed by program)
%m: A time_t value representing a DATE and/or TIME
Example usage: dbi_result_get_fields(result, "idnum.%ul lastname.%s", &id_number, &name)
Result: The target query result.
format: The field format string as described above.
ARG: (...) Pointers to the destination variables corresponding with each field in the format string.
The number of fields fetched, or -1 if there was an error. If an invalid field name was specified it will not cause -1 to be returned, and the other fetched fields will work as usual.
int dbi_result_bind_fields(dbi_result Result, const char *format, ...) |
Bind multiple fields in the current result set, using a printf-like syntax. See dbi_result_get_fields for a detailed explanation of the syntax.
Result: The target query result.
format: The field format string as described above.
ARG: (...) Pointers to the destination variables corresponding with each field in the format string.
The number of field binding set up, or -1 if there was an error.
signed char dbi_result_get_char(dbi_result Result, const char *fieldname) |
Fetch the data stored in the speficied field, which contains a character.
Result: The target query result.
fieldname: The name of the field to fetch.
The data stored in the specified field.
unsigned char dbi_result_get_uchar(dbi_result Result, const char *fieldname) |
Fetch the data stored in the speficied field, which contains an unsigned character.
Result: The target query result.
fieldname: The name of the field to fetch.
The data stored in the specified field.
short dbi_result_get_short(dbi_result Result, const char *fieldname) |
Fetch the data stored in the speficied field, which contains a short integer.
Result: The target query result.
fieldname: The name of the field to fetch.
The data stored in the specified field.
unsigned short dbi_result_get_ushort(dbi_result Result, const char *fieldname) |
Fetch the data stored in the speficied field, which contains an unsigned short integer.
Result: The target query result.
fieldname: The name of the field to fetch.
The data stored in the specified field.
long dbi_result_get_long(dbi_result Result, const char *fieldname) |
Fetch the data stored in the speficied field, which contains a long integer.
Result: The target query result.
fieldname: The name of the field to fetch.
The data stored in the specified field.
unsigned long dbi_result_get_ulong(dbi_result Result, const char *fieldname) |
Fetch the data stored in the speficied field, which contains an unsigned long integer.
Result: The target query result.
fieldname: The name of the field to fetch.
The data stored in the specified field.
long long dbi_result_get_longlong(dbi_result Result, const char *fieldname) |
Fetch the data stored in the speficied field, which contains a long long integer.
Result: The target query result.
fieldname: The name of the field to fetch.
The data stored in the specified field.
unsigned long long dbi_result_get_ulonglong(dbi_result Result, const char *fieldname) |
Fetch the data stored in the speficied field, which contains an unsigned long long integer.
Result: The target query result.
fieldname: The name of the field to fetch.
The data stored in the specified field.
float dbi_result_get_float(dbi_result Result, const char *fieldname) |
Fetch the data stored in the speficied field, which contains a floating-point number.
Result: The target query result.
fieldname: The name of the field to fetch.
The data stored in the specified field.
double dbi_result_get_double(dbi_result Result, const char *fieldname) |
Fetch the data stored in the speficied field, which contains a double-precision fractional number.
Result: The target query result.
fieldname: The name of the field to fetch.
The data stored in the specified field.
const char *dbi_result_get_string(dbi_result Result, const char *fieldname) |
Fetch the data stored in the speficied field, which contains a string. The string may not be modified, and may not necessairly persist between row fetches.
Result: The target query result.
fieldname: The name of the field to fetch.
The data stored in the specified field.
const unsigned char *dbi_result_get_binary(dbi_result Result, const char *fieldname) |
Fetch the data stored in the speficied field, which contains binary BLOB data. The data may not be modified, and may not necessarily persist between row fetches.
Result: The target query result.
fieldname: The name of the field to fetch.
The data stored in the specified field.
char *dbi_result_get_string_copy(dbi_result Result, const char *fieldname) |
Fetch the data stored in the speficied field, which contains a string. The newly allocated string may be modified by the host program, but the program is responsible for freeing the string.
Result: The target query result.
fieldname: The name of the field to fetch.
The data stored in the specified field.
unsigned char *dbi_result_get_binary_copy(dbi_result Result, const char *fieldname) |
Fetch the data stored in the speficied field, which contains binary BLOB data. The newly allocated memory may be modified by the host program, but the program is responsible for freeing the data.
Result: The target query result.
fieldname: The name of the field to fetch.
The data stored in the specified field.
time_t dbi_result_get_datetime(dbi_result Result, const char *fieldname) |
Fetch the data stored in the specified field, which contains a DATE and/or TIME value.
Result: The target query result.
fieldname: The name of the field to fetch.
The data stored in the specified field.
int dbi_result_bind_char(dbi_result Result, const char *fieldname, char *bindto) |
Bind the specified variable to the specified field, which holds a character.
Result: The target query result.
fieldname: The name of the field to bind to.
bindto: A pointer to the variable that will be updated with the specified field's value.
0 upon success, -1 if there was an error
int dbi_result_bind_uchar(dbi_result Result, const char *fieldname, unsigned char *bindto) |
Bind the specified variable to the specified field, which holds an unsigned character.
Result: The target query result.
fieldname: The name of the field to bind to.
bindto: A pointer to the variable that will be updated with the specified field's value.
0 upon success, -1 if there was an error
int dbi_result_bind_short(dbi_result Result, const char *fieldname, short *bindto) |
Bind the specified variable to the specified field, which holds a short integer.
Result: The target query result.
fieldname: The name of the field to bind to.
bindto: A pointer to the variable that will be updated with the specified field's value.
0 upon success, -1 if there was an error
int dbi_result_bind_ushort(dbi_result Result, const char *fieldname, unsigned short *bindto) |
Bind the specified variable to the specified field, which holds an unsigned short integer.
Result: The target query result.
fieldname: The name of the field to bind to.
bindto: A pointer to the variable that will be updated with the specified field's value.
0 upon success, -1 if there was an error
int dbi_result_bind_long(dbi_result Result, const char *fieldname, long *bindto) |
Bind the specified variable to the specified field, which holds a long integer.
Result: The target query result.
fieldname: The name of the field to bind to.
bindto: A pointer to the variable that will be updated with the specified field's value.
0 upon success, -1 if there was an error
int dbi_result_bind_ulong(dbi_result Result, const char *fieldname, unsigned long *bindto) |
Bind the specified variable to the specified field, which holds an unsigned long integer.
Result: The target query result.
fieldname: The name of the field to bind to.
bindto: A pointer to the variable that will be updated with the specified field's value.
0 upon success, -1 if there was an error
int dbi_result_bind_longlong(dbi_result Result, const char *fieldname, long long *bindto) |
Bind the specified variable to the specified field, which holds a long long integer.
Result: The target query result.
fieldname: The name of the field to bind to.
bindto: A pointer to the variable that will be updated with the specified field's value.
0 upon success, -1 if there was an error
int dbi_result_bind_ulonglong(dbi_result Result, const char *fieldname, unsigned long long *bindto) |
Bind the specified variable to the specified field, which holds an unsigned long long integer.
Result: The target query result.
fieldname: The name of the field to bind to.
bindto: A pointer to the variable that will be updated with the specified field's value.
0 upon success, -1 if there was an error
int dbi_result_bind_float(dbi_result Result, const char *fieldname, float *bindto) |
Bind the specified variable to the specified field, which holds a floating-point number.
Result: The target query result.
fieldname: The name of the field to bind to.
bindto: A pointer to the variable that will be updated with the specified field's value.
0 upon success, -1 if there was an error
int dbi_result_bind_double(dbi_result Result, const char *fieldname, double *bindto) |
Bind the specified variable to the specified field, which holds a double-precision fractional number.
Result: The target query result.
fieldname: The name of the field to bind to.
bindto: A pointer to the variable that will be updated with the specified field's value.
0 upon success, -1 if there was an error
int dbi_result_bind_string(dbi_result Result, const char *fieldname, const char **bindto) |
Bind the specified variable to the specified field, which holds a string. The string must not be modified.
Result: The target query result.
fieldname: The name of the field to bind to.
bindto: A pointer to the variable that will be updated with the specified field's value.
0 upon success, -1 if there was an error
int dbi_result_bind_binary(dbi_result Result, const char *fieldname, const unsigned char **bindto) |
Bind the specified variable to the specified field, which holds binary BLOB data. The data must not be modified.
Result: The target query result.
fieldname: The name of the field to bind to.
bindto: A pointer to the variable that will be updated with the specified field's value.
0 upon success, -1 if there was an error
int dbi_result_bind_string_copy(dbi_result Result, const char *fieldname, char **bindto) |
Bind the specified variable to the specified field, which holds a string. The newly allocated string may be modified by the host program, but the program is responsible for freeing the string.
Result: The target query result.
fieldname: The name of the field to bind to.
bindto: A pointer to the variable that will be updated with the specified field's value.
0 upon success, -1 if there was an error
int dbi_result_bind_binary_copy(dbi_result Result, const char *fieldname, unsigned char **bindto) |
Bind the specified variable to the specified field, which holds binary BLOB data. The newly allocated data may be modified by the host program, but the program is responsible for freeing the data.
Result: The target query result.
fieldname: The name of the field to bind to.
bindto: A pointer to the variable that will be updated with the specified field's value.
0 upon success, -1 if there was an error
int dbi_result_bind_datetime(dbi_result Result, const char *fieldname, time_t *bindto) |
Bind the specified variable to the specified field, which holds a DATE and/or TIME value.
Result: The target query result.
fieldname: The name of the field to bind to.
bindto: A pointer to the variable that will be updated with the specified field's value.
0 upon success, -1 if there was an error
signed char dbi_result_get_char_idx(dbi_result Result, unsigned int idx) |
Fetch the data stored in the speficied field, which contains a character.
Result: The target query result.
idx: The index of the target field (starting at 1).
The data stored in the specified field.
unsigned char dbi_result_get_uchar_idx(dbi_result Result, unsigned int idx) |
Fetch the data stored in the speficied field, which contains an unsigned character.
Result: The target query result.
idx: The index of the target field (starting at 1).
The data stored in the specified field.
short dbi_result_get_short_idx(dbi_result Result, unsigned int idx) |
Fetch the data stored in the speficied field, which contains a short integer.
Result: The target query result.
idx: The index of the target field (starting at 1).
The data stored in the specified field.
unsigned short dbi_result_get_ushort_idx(dbi_result Result, unsigned int idx) |
Fetch the data stored in the speficied field, which contains an unsigned short integer.
Result: The target query result.
idx: The index of the target field (starting at 1).
The data stored in the specified field.
long dbi_result_get_long_idx(dbi_result Result, unsigned int idx) |
Fetch the data stored in the speficied field, which contains a long integer.
Result: The target query result.
idx: The index of the target field (starting at 1).
The data stored in the specified field.
unsigned long dbi_result_get_ulong_idx(dbi_result Result, unsigned int idx) |
Fetch the data stored in the speficied field, which contains an unsigned long integer.
Result: The target query result.
idx: The index of the target field (starting at 1).
The data stored in the specified field.
long long dbi_result_get_longlong_idx(dbi_result Result, unsigned int idx) |
Fetch the data stored in the speficied field, which contains a long long integer.
Result: The target query result.
idx: The index of the target field (starting at 1).
The data stored in the specified field.
unsigned long long dbi_result_get_ulonglong_idx(dbi_result Result, unsigned int idx) |
Fetch the data stored in the speficied field, which contains an unsigned long long integer.
Result: The target query result.
idx: The index of the target field (starting at 1).
The data stored in the specified field.
float dbi_result_get_float_idx(dbi_result Result, unsigned int idx) |
Fetch the data stored in the speficied field, which contains a floating-point number.
Result: The target query result.
idx: The index of the target field (starting at 1).
The data stored in the specified field.
double dbi_result_get_double_idx(dbi_result Result, unsigned int idx) |
Fetch the data stored in the speficied field, which contains a double-precision fractional number.
Result: The target query result.
idx: The index of the target field (starting at 1).
The data stored in the specified field.
const char *dbi_result_get_string_idx(dbi_result Result, unsigned int idx) |
Fetch the data stored in the speficied field, which contains a string. The string may not be modified, and may not necessairly persist between row fetches.
Result: The target query result.
idx: The index of the target field (starting at 1).
The data stored in the specified field.
const unsigned char *dbi_result_get_binary_idx(dbi_result Result, unsigned int idx) |
Fetch the data stored in the speficied field, which contains binary BLOB data. The data may not be modified, and may not necessarily persist between row fetches.
Result: The target query result.
idx: The index of the target field (starting at 1).
The data stored in the specified field.
char *dbi_result_get_string_copy_idx(dbi_result Result, unsigned int idx) |
Fetch the data stored in the speficied field, which contains a string. The newly allocated string may be modified by the host program, but the program is responsible for freeing the string.
Result: The target query result.
idx: The index of the target field (starting at 1).
The data stored in the specified field.
unsigned char *dbi_result_get_binary_copy_idx(dbi_result Result, unsigned int idx) |
Fetch the data stored in the speficied field, which contains binary BLOB data. The newly allocated memory may be modified by the host program, but the program is responsible for freeing the data.
Result: The target query result.
idx: The index of the target field (starting at 1).
The data stored in the specified field.
time_t dbi_result_get_datetime_idx(dbi_result Result, unsigned int idx) |
Fetch the data stored in the specified field, which contains a DATE and/or TIME value.
Result: The target query result.
idx: The index of the target field (starting at 1).
The data stored in the specified field.