From 5694c0a4529334756f2b914ad67408df199551dc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 21 Aug 2011 16:27:34 +0200 Subject: Add odb::connection class This abstract class represents a connection to the database. One can use it to start a transaction or to execute a native statement out of a transaction. Before we had concrete connection classes in the database runtime libraries (e.g., odb::mysql::connection). Now these classes derive from odb::connection. --- odb/sqlite/database.cxx | 41 ++++------------------------------------- 1 file changed, 4 insertions(+), 37 deletions(-) (limited to 'odb/sqlite/database.cxx') diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx index 912ec97..e756608 100644 --- a/odb/sqlite/database.cxx +++ b/odb/sqlite/database.cxx @@ -6,10 +6,8 @@ #include #include -#include #include #include -#include #include #include @@ -80,42 +78,11 @@ namespace odb details::options::print_usage (os); } - unsigned long long database:: - execute (const char* s, std::size_t n) + odb::connection* database:: + connection_ () { - if (!transaction::has_current ()) - throw not_in_transaction (); - - connection_type& c (transaction::current ().connection ()); - simple_statement st (c, s, n); - return st.execute (); - } - - transaction_impl* database:: - begin () - { - if (transaction::has_current ()) - throw already_in_transaction (); - - return new transaction_impl (*this, transaction_impl::deferred); - } - - transaction_impl* database:: - begin_immediate () - { - if (transaction::has_current ()) - throw already_in_transaction (); - - return new transaction_impl (*this, transaction_impl::immediate); - } - - transaction_impl* database:: - begin_exclusive () - { - if (transaction::has_current ()) - throw already_in_transaction (); - - return new transaction_impl (*this, transaction_impl::exclusive); + connection_ptr c (factory_->connect ()); + return c.release (); } } } -- cgit v1.1