|
Functions | |
| Q_DB * | qDb (const char *dbtype, const char *addr, int port, const char *username, const char *password, const char *database, bool autocommit) |
| Initialize internal connector structure. | |
| static bool | _open (Q_DB *db) |
| Q_DB->open(): Connect to database server. | |
| static bool | _close (Q_DB *db) |
| Q_DB->close(): Disconnect from database server. | |
| static int | _executeUpdate (Q_DB *db, const char *query) |
| Q_DB->executeUpdate(): Executes the update DML. | |
| static int | _executeUpdatef (Q_DB *db, const char *format,...) |
| Q_DB->executeUpdatef(): Executes the formatted update DML. | |
| static Q_DBRESULT * | _executeQuery (Q_DB *db, const char *query) |
| Q_DB->executeQuery(): Executes the query. | |
| static Q_DBRESULT * | _executeQueryf (Q_DB *db, const char *format,...) |
| Q_DB->executeQueryf(): Executes the formatted query. | |
| static bool | _beginTran (Q_DB *db) |
| Q_DB->beginTran(): Start transaction. | |
| static bool | _commit (Q_DB *db) |
| Q_DB->commit(): Commit transaction. | |
| static bool | _rollback (Q_DB *db) |
| Q_DB->rellback(): Roll-back and abort transaction. | |
| static bool | _setFetchType (Q_DB *db, bool use) |
| Q_DB->setFetchType(): Set result fetching type. | |
| static bool | _getConnStatus (Q_DB *db) |
| Q_DB->getConnStatus(): Get last connection status. | |
| static bool | _ping (Q_DB *db) |
| Q_DB->ping(): Checks whether the connection to the server is working. | |
| static const char * | _getError (Q_DB *db, unsigned int *errorno) |
| Q_DB->getError(): Get error number and message. | |
| static bool | _free (Q_DB *db) |
| Q_DB->free(): De-allocate Q_DB structure. | |
| static const char * | _resultGetStr (Q_DBRESULT *result, const char *field) |
| Q_DBRESULT->getStr(): Get the result as string by field name. | |
| static const char * | _resultGetStrAt (Q_DBRESULT *result, int idx) |
| Q_DBRESULT->getStrAt(): Get the result as string by column number. | |
| static int | _resultGetInt (Q_DBRESULT *result, const char *field) |
| Q_DBRESULT->getInt(): Get the result as integer by field name. | |
| static int | _resultGetIntAt (Q_DBRESULT *result, int idx) |
| Q_DBRESULT->getIntAt(): Get the result as integer by column number. | |
| static bool | _resultGetNext (Q_DBRESULT *result) |
| Q_DBRESULT->getNext(): Retrieves the next row of a result set. | |
| static int | _resultGetCols (Q_DBRESULT *result) |
| Q_DBRESULT->getCols(): Get the number of columns in the result set. | |
| static int | _resultGetRows (Q_DBRESULT *result) |
| Q_DBRESULT->getRows(): Get the number of rows in the result set. | |
| static int | _resultGetRow (Q_DBRESULT *result) |
| Q_DBRESULT->getRow(): Get the current row number. | |
| static bool | _resultFree (Q_DBRESULT *result) |
| Q_DBRESULT->free(): De-allocate the result. | |
[mysql.h header should be included prior to qDecoder.h header to let qDecoder know that.] #include "mysql.h" #include "qDecoder.h"
Q_DB *db = NULL; Q_DBRESULT *result = NULL; db = qDb("MYSQL", "dbhost.qdecoder.org", 3306, "test", "secret", "sampledb", true); if (db == NULL) { printf("ERROR: Not supported database type.\n"); return -1; } // try to connect if (db->open(db) == false) { printf("WARNING: Can't connect to database.\n"); return -1; } // get results result = db->executeQuery(db, "SELECT name, population FROM City"); if (result != NULL) { printf("COLS : %d , ROWS : %d\n", result->getCols(result), result->getRows(result)); while (result->getNext(result) == true) { char *pszName = result->getStr(result, "name"); int nPopulation = result->getInt(result, "population"); printf("Country : %s , Population : %d\n", pszName, nPopulation); } result->free(result); } // close connection db->close(db); // free db object db->free(db);
| Q_DB* 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 |
| static bool _open | ( | Q_DB * | db | ) | [static] |
Q_DB->open(): Connect to database server.
| db | a pointer of Q_DB object |
| static bool _close | ( | Q_DB * | db | ) | [static] |
Q_DB->close(): Disconnect from database server.
| db | a pointer of Q_DB object |
| static int _executeUpdate | ( | Q_DB * | db, | |
| const char * | query | |||
| ) | [static] |
Q_DB->executeUpdate(): Executes the update DML.
| db | a pointer of Q_DB object | |
| query | query string |
| static int _executeUpdatef | ( | Q_DB * | db, | |
| const char * | format, | |||
| ... | ||||
| ) | [static] |
Q_DB->executeUpdatef(): Executes the formatted update DML.
| db | a pointer of Q_DB object | |
| format | query string format |
| static Q_DBRESULT* _executeQuery | ( | Q_DB * | db, | |
| const char * | query | |||
| ) | [static] |
Q_DB->executeQuery(): Executes the query.
| db | a pointer of Q_DB object | |
| query | query string |
| static Q_DBRESULT* _executeQueryf | ( | Q_DB * | db, | |
| const char * | format, | |||
| ... | ||||
| ) | [static] |
Q_DB->executeQueryf(): Executes the formatted query.
| db | a pointer of Q_DB object | |
| format | query string format |
| static bool _beginTran | ( | Q_DB * | db | ) | [static] |
Q_DB->beginTran(): Start transaction.
| db | a pointer of Q_DB object |
| static bool _commit | ( | Q_DB * | db | ) | [static] |
Q_DB->commit(): Commit transaction.
| db | a pointer of Q_DB object |
| static bool _rollback | ( | Q_DB * | db | ) | [static] |
Q_DB->rellback(): Roll-back and abort transaction.
| db | a pointer of Q_DB object |
| static bool _setFetchType | ( | Q_DB * | db, | |
| bool | use | |||
| ) | [static] |
Q_DB->setFetchType(): Set result fetching type.
| db | a pointer of Q_DB object | |
| use | false for storing the results to client (default mode), true for fetching directly from server, |
| static bool _getConnStatus | ( | Q_DB * | db | ) | [static] |
Q_DB->getConnStatus(): Get last connection status.
| db | a pointer of Q_DB object |
| static bool _ping | ( | Q_DB * | db | ) | [static] |
Q_DB->ping(): Checks whether the connection to the server is working.
| db | a pointer of Q_DB object |
| static const char* _getError | ( | Q_DB * | db, | |
| unsigned int * | errorno | |||
| ) | [static] |
Q_DB->getError(): Get error number and message.
| db | a pointer of Q_DB object | |
| errorno | if not NULL, error number will be stored |
| static bool _free | ( | Q_DB * | db | ) | [static] |
Q_DB->free(): De-allocate Q_DB structure.
| db | a pointer of Q_DB object |
| static const char* _resultGetStr | ( | Q_DBRESULT * | result, | |
| const char * | field | |||
| ) | [static] |
Q_DBRESULT->getStr(): Get the result as string by field name.
| result | a pointer of Q_DBRESULT | |
| field | column name |
| static const char* _resultGetStrAt | ( | Q_DBRESULT * | result, | |
| int | idx | |||
| ) | [static] |
Q_DBRESULT->getStrAt(): Get the result as string by column number.
| result | a pointer of Q_DBRESULT | |
| idx | column number (first column is 1) |
| static int _resultGetInt | ( | Q_DBRESULT * | result, | |
| const char * | field | |||
| ) | [static] |
Q_DBRESULT->getInt(): Get the result as integer by field name.
| result | a pointer of Q_DBRESULT | |
| field | column name |
| static int _resultGetIntAt | ( | Q_DBRESULT * | result, | |
| int | idx | |||
| ) | [static] |
Q_DBRESULT->getIntAt(): Get the result as integer by column number.
| result | a pointer of Q_DBRESULT | |
| idx | column number (first column is 1) |
| static bool _resultGetNext | ( | Q_DBRESULT * | result | ) | [static] |
Q_DBRESULT->getNext(): Retrieves the next row of a result set.
| result | a pointer of Q_DBRESULT |
| static int _resultGetCols | ( | Q_DBRESULT * | result | ) | [static] |
Q_DBRESULT->getCols(): Get the number of columns in the result set.
| result | a pointer of Q_DBRESULT |
| static int _resultGetRows | ( | Q_DBRESULT * | result | ) | [static] |
Q_DBRESULT->getRows(): Get the number of rows in the result set.
| result | a pointer of Q_DBRESULT |
| static int _resultGetRow | ( | Q_DBRESULT * | result | ) | [static] |
Q_DBRESULT->getRow(): Get the current row number.
| result | a pointer of Q_DBRESULT |
| static bool _resultFree | ( | Q_DBRESULT * | result | ) | [static] |
Q_DBRESULT->free(): De-allocate the result.
| result | a pointer of Q_DBRESULT |
| [Home] [About] [Examples] [Changes] [Download] [SVN Repository] [Install] [Reference] |