Method: Sequel::Dataset#bind

Defined in:
lib/sequel/dataset/prepared_statements.rb

#bind(bind_vars = OPTS) ⇒ Object

Set the bind variables to use for the call. If bind variables have already been set for this dataset, they are updated with the contents of bind_vars.

DB[:table].where(id: :$id).bind(id: 1).call(:first)
# SELECT * FROM table WHERE id = ? LIMIT 1 -- (1)
# => {:id=>1}
[View source]

333
334
335
336
337
338
339
340
341
342
343
344
345
# File 'lib/sequel/dataset/prepared_statements.rb', line 333

def bind(bind_vars=OPTS)
  bind_vars = if bv = @opts[:bind_vars]
    bv.merge(bind_vars).freeze
  else
    if bind_vars.frozen?
      bind_vars
    else
      Hash[bind_vars]
    end
  end

  clone(:bind_vars=>bind_vars)
end