00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TNTDB_BITS_CONNECTION_H
00020 #define TNTDB_BITS_CONNECTION_H
00021
00022 #include <string>
00023 #include <cxxtools/smartptr.h>
00024 #include <tntdb/iface/iconnection.h>
00025 #include <tntdb/bits/statement.h>
00026
00027 namespace tntdb
00028 {
00029 class Result;
00030 class Row;
00031 class Value;
00032 class Statement;
00033
00056 class Connection
00057 {
00058 public:
00059 typedef unsigned size_type;
00060
00061 private:
00062 cxxtools::SmartPtr<IConnection> conn;
00063
00064 public:
00068 Connection() { }
00072 Connection(IConnection* conn_)
00073 : conn(conn_)
00074 { }
00075
00080 void close()
00081 { conn = 0; }
00082
00087 void beginTransaction();
00091 void commitTransaction();
00095 void rollbackTransaction();
00096
00104 size_type execute(const std::string& query);
00109 Result select(const std::string& query);
00115 Row selectRow(const std::string& query);
00121 Value selectValue(const std::string& query);
00125 Statement prepare(const std::string& query);
00131 Statement prepareCached(const std::string& query);
00132
00136 void clearStatementCache() { conn->clearStatementCache(); }
00137
00141 bool ping() { return conn->ping(); }
00142
00146 bool operator!() const { return !conn; }
00150 const IConnection* getImpl() const { return &*conn; }
00151 };
00152 }
00153
00154 #endif // TNTDB_BITS_CONNECTION_H
00155