Class: Libsql::Statement
- Inherits:
-
Object
- Object
- Libsql::Statement
- Defined in:
- lib/libsql.rb
Instance Method Summary collapse
- #bind(params) ⇒ Object
- #close ⇒ Object
- #closed? ⇒ Boolean
- #column_count ⇒ Object
- #execute(params = []) ⇒ Object
-
#initialize(inner) ⇒ Statement
constructor
A new instance of Statement.
- #query(params = []) ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize(inner) ⇒ Statement
Returns a new instance of Statement.
377 378 379 |
# File 'lib/libsql.rb', line 377 def initialize(inner) @inner = inner end |
Instance Method Details
#bind(params) ⇒ Object
381 382 383 384 385 386 387 388 389 390 391 |
# File 'lib/libsql.rb', line 381 def bind(params) raise ClosedException if closed? case params in Array then params.each { |v| @inner.bind_value convert(v) } in Hash params.each do |k, v| @inner.bind_named case k when Symbol then ":#{k}" else k end, convert(v) end end end |
#close ⇒ Object
422 423 424 425 426 427 |
# File 'lib/libsql.rb', line 422 def close raise ClosedException if closed? @inner.deinit @inner = nil end |
#closed? ⇒ Boolean
429 430 431 |
# File 'lib/libsql.rb', line 429 def closed? @inner.nil? end |
#column_count ⇒ Object
410 411 412 413 414 |
# File 'lib/libsql.rb', line 410 def column_count raise ClosedException if closed? @inner.column_count end |
#execute(params = []) ⇒ Object
393 394 395 396 397 398 |
# File 'lib/libsql.rb', line 393 def execute(params = []) raise ClosedException if closed? bind params @inner.execute[:rows_changed] end |
#query(params = []) ⇒ Object
400 401 402 403 404 405 406 407 408 |
# File 'lib/libsql.rb', line 400 def query(params = []) raise ClosedException if closed? bind params rows = Rows.new @inner.query return rows unless block_given? begin yield rows ensure rows.close end end |
#reset ⇒ Object
416 417 418 419 420 |
# File 'lib/libsql.rb', line 416 def reset raise ClosedException if closed? @inner.reset end |