00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef TNTDB_BITS_CONNECTION_H
00030 #define TNTDB_BITS_CONNECTION_H
00031
00032 #include <string>
00033 #include <cxxtools/smartptr.h>
00034 #include <tntdb/iface/iconnection.h>
00035 #include <tntdb/bits/statement.h>
00036
00037 namespace tntdb
00038 {
00039 class Result;
00040 class Row;
00041 class Value;
00042 class Statement;
00043
00066 class Connection
00067 {
00068 public:
00069 typedef unsigned size_type;
00070
00071 private:
00072 cxxtools::SmartPtr<IConnection> conn;
00073
00074 public:
00078 Connection() { }
00082 Connection(IConnection* conn_)
00083 : conn(conn_)
00084 { }
00085
00090 void close()
00091 { conn = 0; }
00092
00097 void beginTransaction();
00101 void commitTransaction();
00105 void rollbackTransaction();
00106
00114 size_type execute(const std::string& query);
00119 Result select(const std::string& query);
00125 Row selectRow(const std::string& query);
00131 Value selectValue(const std::string& query);
00135 Statement prepare(const std::string& query);
00136
00144 Statement prepareCached(const std::string& query, const std::string& key);
00145
00151 Statement prepareCached(const std::string& query)
00152 { return prepareCached(query, query); }
00153
00157 void clearStatementCache() { conn->clearStatementCache(); }
00158
00162 bool ping() { return conn->ping(); }
00163
00167 long lastInsertId(const std::string& name = std::string())
00168 { return conn->lastInsertId(name); }
00169
00173 bool operator!() const { return !conn; }
00177 const IConnection* getImpl() const { return &*conn; }
00178 };
00179 }
00180
00181 #endif // TNTDB_BITS_CONNECTION_H
00182