aboutsummaryrefslogtreecommitdiff
path: root/odb/mysql/statement.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-07-30 13:27:14 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-07-30 13:27:14 +0200
commit7f528c0bc15ad9b192a61636aec59ece84f35a12 (patch)
treee0a04acdd9630fb71feb017067289b129aad3fa4 /odb/mysql/statement.txx
parenta559fc0b0cb8e3a4de91680773a8f4fea2c9a3d3 (diff)
Add the rest of the statements
Diffstat (limited to 'odb/mysql/statement.txx')
-rw-r--r--odb/mysql/statement.txx45
1 files changed, 11 insertions, 34 deletions
diff --git a/odb/mysql/statement.txx b/odb/mysql/statement.txx
index 4f82942..95579b4 100644
--- a/odb/mysql/statement.txx
+++ b/odb/mysql/statement.txx
@@ -6,48 +6,25 @@
#include <cstddef> // std::size_t
#include <cstring> // std::memset
-#include <odb/mysql/exceptions.hxx>
-
namespace odb
{
namespace mysql
{
- template <typename T>
- insert_statement<T>::
- ~insert_statement ()
- {
- }
-
- template <typename T>
- insert_statement<T>::
- insert_statement (connection& conn,
- const std::string& query,
- image_type& image)
- : statement (conn), image_ (image)
- {
- if (mysql_stmt_prepare (stmt_, query.c_str (), query.size ()) != 0)
- throw database_exception (stmt_);
-
- std::memset (bind_, 0, sizeof (bind_));
- }
+ // object_statements
+ //
template <typename T>
- void insert_statement<T>::
- execute ()
+ object_statements<T>::
+ object_statements (connection& conn)
+ : object_statements_base (conn),
+ image_binding_ (image_bind_, object_traits::column_count),
+ id_image_binding_ (image_bind_ + object_traits::column_count, 1)
{
- if (mysql_stmt_reset (stmt_))
- throw database_exception (stmt_);
-
- object_traits::bind (bind_, image_);
-
- if (mysql_stmt_bind_param (stmt_, bind_))
- throw database_exception (stmt_);
-
- if (mysql_stmt_execute (stmt_))
- throw database_exception (stmt_);
+ std::memset (image_bind_, 0, sizeof (image_bind_));
+ std::memset (image_error_, 0, sizeof (image_error_));
- if (mysql_stmt_affected_rows (stmt_) != 1)
- throw object_already_persistent ();
+ for (std::size_t i (0); i < object_traits::column_count; ++i)
+ image_bind_[i].error = image_error_ + i;
}
}
}