qLibc
|
Database wrapper. More...
Go to the source code of this file.
Functions | |
qdb_t * | qdb (const char *dbtype, const char *addr, int port, const char *username, const char *password, const char *database, bool autocommit) |
Initialize internal connector structure. More... | |
static bool | open_ (qdb_t *db) |
qdb->open(): Connect to database server More... | |
static bool | close_ (qdb_t *db) |
qdb->close(): Disconnect from database server More... | |
static int | execute_update (qdb_t *db, const char *query) |
qdb->execute_update(): Executes the update DML More... | |
static int | execute_updatef (qdb_t *db, const char *format,...) |
qdb->execute_updatef(): Executes the formatted update DML More... | |
static qdbresult_t * | execute_query (qdb_t *db, const char *query) |
qdb->execute_query(): Executes the query More... | |
static qdbresult_t * | execute_queryf (qdb_t *db, const char *format,...) |
qdb->execute_queryf(): Executes the formatted query More... | |
static bool | begin_tran (qdb_t *db) |
qdb->begin_tran(): Start transaction More... | |
static bool | commit (qdb_t *db) |
qdb->commit(): Commit transaction More... | |
static bool | rollback (qdb_t *db) |
qdb->rellback(): Roll-back and abort transaction More... | |
static bool | set_fetchtype (qdb_t *db, bool fromdb) |
qdb->set_fetchtype(): Set result fetching type More... | |
static bool | get_conn_status (qdb_t *db) |
qdb->get_conn_status(): Get last connection status More... | |
static bool | ping (qdb_t *db) |
qdb->ping(): Checks whether the connection to the server is working. More... | |
static const char * | get_error (qdb_t *db, unsigned int *errorno) |
qdb->get_error(): Get error number and message More... | |
static void | free_ (qdb_t *db) |
qdb->free(): De-allocate qdb_t structure More... | |
static const char * | _resultGetStr (qdbresult_t *result, const char *field) |
qdbresult->get_str(): Get the result as string by field name More... | |
static const char * | _resultGetStrAt (qdbresult_t *result, int idx) |
qdbresult->get_str_at(): Get the result as string by column number More... | |
static int | _resultGetInt (qdbresult_t *result, const char *field) |
qdbresult->get_int(): Get the result as integer by field name More... | |
static int | _resultGetIntAt (qdbresult_t *result, int idx) |
qdbresult->get_int_at(): Get the result as integer by column number More... | |
static bool | _resultGetNext (qdbresult_t *result) |
qdbresult->get_next(): Retrieves the next row of a result set More... | |
static int | result_get_cols (qdbresult_t *result) |
qdbresult->get_cols(): Get the number of columns in the result set More... | |
static int | result_get_rows (qdbresult_t *result) |
qdbresult->get_rows(): Get the number of rows in the result set More... | |
static int | result_get_row (qdbresult_t *result) |
qdbresult->get_row(): Get the current row number More... | |
static void | result_free (qdbresult_t *result) |
qdbresult->free(): De-allocate the result More... | |
Database wrapper.
Database header files should be included prior to qlibcext.h in your source codes like below.
Definition in file qdatabase.c.
qdb_t* qdb | ( | const char * | dbtype, |
const char * | addr, | ||
int | port, | ||
const char * | username, | ||
const char * | password, | ||
const char * | database, | ||
bool | autocommit | ||
) |
Initialize internal connector structure.
dbtype | database server type. currently "MYSQL" is only supported |
addr | ip or fqdn address. |
port | port number |
username | database username |
password | database password |
database | database server type. currently "MYSQL" is only supported |
autocommit | sets autocommit mode on if autocommit is true, off if autocommit is false |
Definition at line 162 of file qdatabase.c.
|
static |
qdb->open(): Connect to database server
db | a pointer of qdb_t object |
Definition at line 232 of file qdatabase.c.
|
static |
qdb->close(): Disconnect from database server
db | a pointer of qdb_t object |
Definition at line 323 of file qdatabase.c.
|
static |
qdb->execute_update(): Executes the update DML
db | a pointer of qdb_t object |
query | query string |
Definition at line 352 of file qdatabase.c.
|
static |
qdb->execute_updatef(): Executes the formatted update DML
db | a pointer of qdb_t object |
format | query string format |
Definition at line 383 of file qdatabase.c.
|
static |
qdb->execute_query(): Executes the query
db | a pointer of qdb_t object |
query | query string |
Definition at line 403 of file qdatabase.c.
|
static |
qdb->execute_queryf(): Executes the formatted query
db | a pointer of qdb_t object |
format | query string format |
Definition at line 460 of file qdatabase.c.
|
static |
qdb->begin_tran(): Start transaction
db | a pointer of qdb_t object |
Definition at line 484 of file qdatabase.c.
|
static |
qdb->commit(): Commit transaction
db | a pointer of qdb_t object |
Definition at line 515 of file qdatabase.c.
|
static |
qdb->rellback(): Roll-back and abort transaction
db | a pointer of qdb_t object |
Definition at line 541 of file qdatabase.c.
|
static |
qdb->set_fetchtype(): Set result fetching type
db | a pointer of qdb_t object |
fromdb | false for storing the results to client (default mode), true for fetching directly from server, |
Definition at line 577 of file qdatabase.c.
|
static |
qdb->get_conn_status(): Get last connection status
db | a pointer of qdb_t object |
Definition at line 594 of file qdatabase.c.
|
static |
qdb->ping(): Checks whether the connection to the server is working.
db | a pointer of qdb_t object |
Definition at line 612 of file qdatabase.c.
|
static |
qdb->get_error(): Get error number and message
db | a pointer of qdb_t object |
errorno | if not NULL, error number will be stored |
Definition at line 643 of file qdatabase.c.
|
static |
qdb->free(): De-allocate qdb_t structure
db | a pointer of qdb_t object |
Definition at line 666 of file qdatabase.c.
|
static |
qdbresult->get_str(): Get the result as string by field name
result | a pointer of qdbresult_t |
field | column name |
Definition at line 698 of file qdatabase.c.
|
static |
qdbresult->get_str_at(): Get the result as string by column number
result | a pointer of qdbresult_t |
idx | column number (first column is 1) |
Definition at line 726 of file qdatabase.c.
|
static |
qdbresult->get_int(): Get the result as integer by field name
result | a pointer of qdbresult_t |
field | column name |
Definition at line 750 of file qdatabase.c.
|
static |
qdbresult->get_int_at(): Get the result as integer by column number
result | a pointer of qdbresult_t |
idx | column number (first column is 1) |
Definition at line 765 of file qdatabase.c.
|
static |
qdbresult->get_next(): Retrieves the next row of a result set
result | a pointer of qdbresult_t |
Definition at line 779 of file qdatabase.c.
|
static |
qdbresult->get_cols(): Get the number of columns in the result set
result | a pointer of qdbresult_t |
Definition at line 800 of file qdatabase.c.
|
static |
qdbresult->get_rows(): Get the number of rows in the result set
result | a pointer of qdbresult_t |
Definition at line 817 of file qdatabase.c.
|
static |
qdbresult->get_row(): Get the current row number
result | a pointer of qdbresult_t |
Definition at line 837 of file qdatabase.c.
|
static |
qdbresult->free(): De-allocate the result
result | a pointer of qdbresult_t |
Definition at line 852 of file qdatabase.c.