Class: SQLite3::Statement
- Inherits:
-
Object
- Object
- SQLite3::Statement
- Defined in:
- lib/motion-sqlite3/statement.rb
Instance Method Summary collapse
- #done? ⇒ Boolean
- #execute ⇒ Object
- #finalize ⇒ Object
-
#initialize(db, sql, params) ⇒ Statement
constructor
A new instance of Statement.
- #step ⇒ Object
Constructor Details
#initialize(db, sql, params) ⇒ Statement
Returns a new instance of Statement.
3 4 5 6 7 8 9 10 |
# File 'lib/motion-sqlite3/statement.rb', line 3 def initialize(db, sql, params) @db = db @handle = Pointer.new(::Sqlite3_stmt.type) @result = nil prepare(sql) bind(params) end |
Instance Method Details
#done? ⇒ Boolean
12 13 14 |
# File 'lib/motion-sqlite3/statement.rb', line 12 def done? @result == SQLITE_DONE end |
#execute ⇒ Object
16 17 18 19 20 |
# File 'lib/motion-sqlite3/statement.rb', line 16 def execute step ResultSet.new(self, @handle) end |
#finalize ⇒ Object
22 23 24 |
# File 'lib/motion-sqlite3/statement.rb', line 22 def finalize sqlite3_finalize(@handle.value) end |
#step ⇒ Object
26 27 28 29 30 31 |
# File 'lib/motion-sqlite3/statement.rb', line 26 def step @result = sqlite3_step(@handle.value) unless @result == SQLITE_DONE || @result == SQLITE_ROW raise SQLite3Error, sqlite3_errmsg(@db.value) end end |