| Revision 1 (by moose, 2006/03/06 10:00:33) |
Initial Import
|
#ifndef __MADSQLITE_H__
#define __MADSQLITE_H__
#include <sqlite3.h>
#include "MadDB.h"
class MadSQLiteResult : public MadDBResult {
public:
MadSQLiteResult();
~MadSQLiteResult();
int reset();
int step();
const void *columnBlob(int);
int columnBytes(int);
double columnDouble(int);
int columnInt(int);
const char *columnText(int);
int columnType(int);
int columnCount();
int bindBlob(int, const void*, int n);
int bindDouble(int, double);
int bindInt(int, int);
int bindNull(int);
int bindText(int, const char*);
private:
friend class MadSQLite;
bool first;
sqlite3_stmt *statement;
};
class MadSQLite : public MadDBConnection {
public:
MadSQLite() : transaction(0), handle(0), dbname(0) { }
~MadSQLite() { if(handle) disconnect(); }
bool connect();
bool disconnect();
bool server(const char *s) { return true; }
const char *server() { return ""; }
bool user(const char *u) { return true; }
const char *user() { return ""; }
bool password(const char *pw) { return true; }
const char *password() { return ""; }
bool database(const char *db) { dbname = strdup(db); return !(!dbname); }
const char *database() { return dbname; }
// transactions
bool begin();
bool commit();
bool rollback();
MadSQLiteResult *prepare(const char *);
MadSQLiteResult *preparef(const char *, ...);
bool query(const char *);
bool queryf(const char *, ...);
int last_insert_id();
const char *error_message();
private:
friend class MadSQLiteResult;
int transaction;
sqlite3 *handle;
char *dbname;
};
#endif /* __MADSQLITE_H__ */