#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdarg.h>
#include <string.h>
#include "qDecoder.h"
#include "qInternal.h"
Go to the source code of this file.
FunctionsTitleTestFour | |
bool | qDbBeginTran (Q_DB *db) |
bool | qDbClose (Q_DB *db) |
bool | qDbCommit (Q_DB *db) |
bool | qDbEndTran (Q_DB *db, bool commit) |
Q_DBRESULT * | qDbExecuteQuery (Q_DB *db, const char *query) |
Q_DBRESULT * | qDbExecuteQueryf (Q_DB *db, const char *format,...) |
int | qDbExecuteUpdate (Q_DB *db, const char *query) |
int | qDbExecuteUpdatef (Q_DB *db, const char *format,...) |
bool | qDbFree (Q_DB *db) |
int | qDbGetCols (Q_DBRESULT *result) |
const char * | qDbGetError (Q_DB *db, unsigned int *errorno) |
int | qDbGetInt (Q_DBRESULT *result, const char *field) |
int | qDbGetIntAt (Q_DBRESULT *result, int idx) |
bool | qDbGetLastConnStatus (Q_DB *db) |
int | qDbGetRow (Q_DBRESULT *result) |
int | qDbGetRows (Q_DBRESULT *result) |
const char * | qDbGetStr (Q_DBRESULT *result, const char *field) |
const char * | qDbGetStrAt (Q_DBRESULT *result, int idx) |
Q_DB * | qDbInit (const char *dbtype, const char *addr, int port, const char *username, const char *password, const char *database, bool autocommit) |
bool | qDbOpen (Q_DB *db) |
bool | qDbPing (Q_DB *db) |
bool | qDbResultFree (Q_DBRESULT *result) |
bool | qDbResultNext (Q_DBRESULT *result) |
bool | qDbRollback (Q_DB *db) |
bool | qDbSetFetchType (Q_DB *db, bool use) |
[include order at your source codes] #include "mysql.h" #include "qDecoder.h"
Not documented yet, please refer below sample codes.
Q_DB *db = NULL; Q_DBRESULT *result = NULL; db = qDbInit("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 (qDbOpen(db) == false) { printf("WARNING: Can't connect to database.\n"); return -1; } // get results result = qDbExecuteQuery(db, "SELECT name, population FROM City"); if (result != NULL) { printf("COLS : %d , ROWS : %d\n", qDbGetCols(result), qDbGetRows(result)); while (qDbResultNext(result) == true) { char *pszName = qDbGetValue(result, "name"); int nPopulation = qDbGetInt(result, "population"); printf("Country : %s , Population : %d\n", pszName, nPopulation); } qDbResultFree(result); } // close connection qDbClose(db); // free db object qDbFree(db);
Definition in file qDatabase.c.