// file : odb/mysql/statement.txx // author : Boris Kolpackov // copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file #include // std::size_t #include // std::memset #include namespace odb { namespace mysql { template insert_statement:: ~insert_statement () { } template insert_statement:: 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_)); } template void insert_statement:: execute () { 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_); if (mysql_stmt_affected_rows (stmt_) != 1) throw object_already_persistent (); } } }