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.
374 375 376 |
# File 'lib/libsql.rb', line 374 def initialize(inner) @inner = inner end |
Instance Method Details
#bind(params) ⇒ Object
378 379 380 381 382 383 384 385 386 387 388 |
# File 'lib/libsql.rb', line 378 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
419 420 421 422 423 424 |
# File 'lib/libsql.rb', line 419 def close raise ClosedException if closed? @inner.deinit @inner = nil end |
#closed? ⇒ Boolean
426 427 428 |
# File 'lib/libsql.rb', line 426 def closed? @inner.nil? end |
#column_count ⇒ Object
407 408 409 410 411 |
# File 'lib/libsql.rb', line 407 def column_count raise ClosedException if closed? @inner.column_count end |
#execute(params = []) ⇒ Object
390 391 392 393 394 395 |
# File 'lib/libsql.rb', line 390 def execute(params = []) raise ClosedException if closed? bind params @inner.execute[:rows_changed] end |
#query(params = []) ⇒ Object
397 398 399 400 401 402 403 404 405 |
# File 'lib/libsql.rb', line 397 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
413 414 415 416 417 |
# File 'lib/libsql.rb', line 413 def reset raise ClosedException if closed? @inner.reset end |