The qDecoder Project

qDatabase.c File Reference

Database Independent Wrapper API. More...


Functions

Q_DBqDbInit (const char *dbtype, const char *addr, int port, const char *username, const char *password, const char *database, bool autocommit)
 Under-development.
bool qDbOpen (Q_DB *db)
 Under-development.
bool qDbClose (Q_DB *db)
 Under-development.
bool qDbFree (Q_DB *db)
 Under-development.
const char * qDbGetError (Q_DB *db, unsigned int *errorno)
 Under-development.
bool qDbPing (Q_DB *db)
 Under-development.
bool qDbGetLastConnStatus (Q_DB *db)
 Under-development.
int qDbExecuteUpdate (Q_DB *db, const char *query)
 Under-development.
int qDbExecuteUpdatef (Q_DB *db, const char *format,...)
 Under-development.
Q_DBRESULTqDbExecuteQuery (Q_DB *db, const char *query)
 Under-development.
Q_DBRESULTqDbExecuteQueryf (Q_DB *db, const char *format,...)
 Under-development.
bool qDbResultNext (Q_DBRESULT *result)
 Under-development.
bool qDbResultFree (Q_DBRESULT *result)
 Under-development.
int qDbGetCols (Q_DBRESULT *result)
 Under-development.
int qDbGetRows (Q_DBRESULT *result)
 Under-development.
int qDbGetRow (Q_DBRESULT *result)
 Retrieves the current row number.
const char * qDbGetStr (Q_DBRESULT *result, const char *field)
 Under-development.
const char * qDbGetStrAt (Q_DBRESULT *result, int idx)
 Under-development.
int qDbGetInt (Q_DBRESULT *result, const char *field)
 Under-development.
int qDbGetIntAt (Q_DBRESULT *result, int idx)
 Under-development.
bool qDbBeginTran (Q_DB *db)
 Under-development.
bool qDbEndTran (Q_DB *db, bool commit)
 Under-development.
bool qDbCommit (Q_DB *db)
 Under-development.
bool qDbRollback (Q_DB *db)
 Under-development.


Detailed Description

Database Independent Wrapper API.

Note:
To use this API, you must include database header file before including qDecoder.h in your source code like below. And please remember that qDecoder must be compiled with ENABLE_MYSQL or ENABLE_SOME_DATABASE option.
   [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);

Function Documentation

Q_DB* qDbInit ( const char *  dbtype,
const char *  addr,
int  port,
const char *  username,
const char *  password,
const char *  database,
bool  autocommit 
)

Under-development.

Since:
not released yet
Note:
   Q_DB *db = NULL;
   db = qDbInit("MYSQL", "dbhost.qdecoder.org", 3306, "test", "secret", "sampledb", true);
   if (db == NULL) {
     printf("ERROR: Not supported database type.\n");
     return -1;
   }

bool qDbOpen ( Q_DB db  ) 

Under-development.

Since:
not released yet

bool qDbClose ( Q_DB db  ) 

Under-development.

Since:
not released yet

bool qDbFree ( Q_DB db  ) 

Under-development.

Since:
not released yet

const char* qDbGetError ( Q_DB db,
unsigned int *  errorno 
)

Under-development.

Since:
not released yet

bool qDbPing ( Q_DB db  ) 

Under-development.

Since:
not released yet

bool qDbGetLastConnStatus ( Q_DB db  ) 

Under-development.

Since:
not released yet

int qDbExecuteUpdate ( Q_DB db,
const char *  query 
)

Under-development.

Since:
not released yet

int qDbExecuteUpdatef ( Q_DB db,
const char *  format,
  ... 
)

Under-development.

Since:
not released yet

Q_DBRESULT* qDbExecuteQuery ( Q_DB db,
const char *  query 
)

Under-development.

Since:
not released yet

Q_DBRESULT* qDbExecuteQueryf ( Q_DB db,
const char *  format,
  ... 
)

Under-development.

Since:
not released yet

bool qDbResultNext ( Q_DBRESULT result  ) 

Under-development.

Since:
not released yet

bool qDbResultFree ( Q_DBRESULT result  ) 

Under-development.

Since:
not released yet

int qDbGetCols ( Q_DBRESULT result  ) 

Under-development.

Since:
not released yet

int qDbGetRows ( Q_DBRESULT result  ) 

Under-development.

Since:
not released yet

int qDbGetRow ( Q_DBRESULT result  ) 

Retrieves the current row number.

Since:
not released yet

const char* qDbGetStr ( Q_DBRESULT result,
const char *  field 
)

Under-development.

Since:
not released yet

const char* qDbGetStrAt ( Q_DBRESULT result,
int  idx 
)

Under-development.

Since:
not released yet

int qDbGetInt ( Q_DBRESULT result,
const char *  field 
)

Under-development.

Since:
not released yet

int qDbGetIntAt ( Q_DBRESULT result,
int  idx 
)

Under-development.

Since:
not released yet

bool qDbBeginTran ( Q_DB db  ) 

Under-development.

Since:
not released yet

bool qDbEndTran ( Q_DB db,
bool  commit 
)

Under-development.

Since:
not released yet

bool qDbCommit ( Q_DB db  ) 

Under-development.

Since:
not released yet

bool qDbRollback ( Q_DB db  ) 

Under-development.

Since:
not released yet


[Home] [About] [Examples] [Changes] [Download] [SVN Repository] [Install] [Reference]