23
23
#include <sqlite3cc/basic_statement.h>
24
24
#include <sqlite3cc/exception.h>
25
#include <sqlite3cc/connection.h>
25
#include <sqlite3cc/database.h>
26
26
#include <sqlite3cc/manipulator.h>
27
27
#include <string.h>
30
sqlite::detail::basic_statement::basic_statement(
31
connection &connection,
30
sqlite::basic_statement::basic_statement(
32
32
const std::string &sql )
34
_connection( connection ),
34
_database( database ),
38
38
int code = prepare( sql );
39
if( code != SQLITE_OK ) throw sqlite_error( connection, code );
39
if( code != SQLITE_OK ) throw sqlite_error( database, code );
43
sqlite::detail::basic_statement::basic_statement(
44
connection &connection )
43
sqlite::basic_statement::basic_statement(
46
_connection( connection ),
46
_database( database ),
53
sqlite::detail::basic_statement::~basic_statement()
53
sqlite::basic_statement::~basic_statement()
59
int sqlite::detail::basic_statement::prepare(
59
int sqlite::basic_statement::prepare(
60
60
const std::string &sql )
63
return sqlite3_prepare_v2( _connection._handle, sql.c_str(),
63
return sqlite3_prepare_v2( _database._handle, sql.c_str(),
64
64
sql.length() + 1, &_handle, NULL );
68
int sqlite::detail::basic_statement::reset()
68
int sqlite::basic_statement::reset()
70
70
return sqlite3_reset( _handle );
74
int sqlite::detail::basic_statement::clear_bindings()
74
int sqlite::basic_statement::clear_bindings()
77
77
return sqlite3_clear_bindings( _handle );
81
int sqlite::detail::basic_statement::bind_static(
81
int sqlite::basic_statement::bind_static(
82
82
unsigned int index,
84
84
unsigned int value_length )
107
int sqlite::detail::basic_statement::bind_null(
107
int sqlite::basic_statement::bind_null(
108
108
unsigned int index )
110
110
return sqlite3_bind_null( _handle, index );
114
int sqlite::detail::basic_statement::bind_static(
114
int sqlite::basic_statement::bind_static(
115
115
const std::string &name,
116
116
const char *value,
117
117
unsigned int value_length )
139
int sqlite::detail::basic_statement::bind_null(
139
int sqlite::basic_statement::bind_null(
140
140
const std::string &name )
142
142
return bind_null( bind_parameter_index( name ) );
146
int sqlite::detail::basic_statement::finalize()
146
int sqlite::basic_statement::finalize()
148
148
int code = SQLITE_OK;
159
int sqlite::detail::basic_statement::bind_parameter_index(
159
int sqlite::basic_statement::bind_parameter_index(
160
160
const std::string &name )
162
162
unsigned int index = sqlite3_bind_parameter_index( _handle, name.c_str() );
176
sqlite::detail::basic_statement &sqlite::detail::basic_statement::operator <<
176
sqlite::basic_statement &sqlite::basic_statement::operator <<
177
177
< sqlite::detail::null_t >(
178
178
const sqlite::detail::null_t & )
180
180
int code = bind_null( _bind_index );
181
if( code != SQLITE_OK ) throw sqlite_error( _connection, code );
181
if( code != SQLITE_OK ) throw sqlite_error( _database, code );
188
sqlite::detail::basic_statement &sqlite::detail::basic_statement::operator <<
188
sqlite::basic_statement &sqlite::basic_statement::operator <<
189
189
< sqlite::detail::set_index_t >(
190
190
const sqlite::detail::set_index_t &t )