31
29
database &database,
32
30
const std::string &sql )
34
basic_statement( database, sql ),
32
basic_statement( database, sql )
37
34
assert( sqlite3_column_count( _handle ) > 0 );
50
46
int sqlite::query::prepare(
51
47
const std::string &sql )
54
int code = basic_statement::prepare( sql );
55
assert( code != SQLITE_OK || sqlite3_column_count( _handle ) > 0 );
49
int error_code = basic_statement::prepare( sql );
50
assert( error_code != SQLITE_OK || sqlite3_column_count( _handle ) > 0 );
60
55
sqlite::row sqlite::query::step()
62
database::database_mutex_guard lock( _database );
64
int code = basic_statement::step();
65
if( code == SQLITE_DONE ) return row();
66
if( code == SQLITE_ROW ) return row( _handle, _next_row++ );
68
throw sqlite_error( _database, code );
57
int error_code = basic_statement::step();
58
if( error_code == SQLITE_ROW )
60
if( error_code == SQLITE_DONE )
61
return row( *this, false );
62
throw sqlite_error( error_code );
74
68
return sqlite3_column_count( _handle );
78
const std::string sqlite::query::column_name(
82
static_cast< unsigned int >( sqlite3_column_count( _handle ) ) );
83
return sqlite3_column_name( _handle, index );
87
sqlite::query::iterator::iterator(
100
sqlite::row sqlite::query::iterator::dereference() const
102
return sqlite::row( _query._handle, _query._next_row++ );
106
void sqlite::query::iterator::increment()
108
_valid = _query.step();
112
bool sqlite::query::iterator::equal(
113
sqlite::query::iterator const &other )
116
return _valid == other._valid;
120
sqlite::query::iterator sqlite::query::begin()
122
return sqlite::query::iterator( *this, true );
126
sqlite::query::iterator sqlite::query::end()
128
return sqlite::query::iterator( *this, false );
133
sqlite::query &sqlite::query::operator <<
134
< sqlite::detail::null_t >(
135
const sqlite::detail::null_t & )
137
int code = bind_null( _bind_index );
138
if( code != SQLITE_OK ) throw sqlite_error( _database, code );
145
sqlite::query &sqlite::query::operator <<
146
< sqlite::detail::set_index_t >(
147
const sqlite::detail::set_index_t &t )
149
_bind_index = t._index;