Class: SQLStatement::Update
Overview
Creates a statement of the form
UPDATE tables SET field=value, field2=value2 WHERE ...
This descends from SelectStatement. Even though the strings are very different, they have lots of other stuff in common.
Instance Attribute Summary
Attributes inherited from Select
Instance Method Summary collapse
-
#field(expression, targetfield) ⇒ Object
Set a field to contain a value.
- #placeheld ⇒ Object
- #to_s ⇒ Object
Methods inherited from Select
#+, #<<, #allfields, #condition, #groupby, #initialize, #leftjoin, newlists, #orderby, #table, #to_sqlpart
Constructor Details
This class inherits a constructor from SQLStatement::Select
Instance Method Details
#field(expression, targetfield) ⇒ Object
Set a field to contain a value. Note the order of the parameters matches the order used for the Select statement
450 451 452 |
# File 'lib/sql/statement.rb', line 450 def field expression, targetfield super expression, targetfield end |
#placeheld ⇒ Object
444 445 446 |
# File 'lib/sql/statement.rb', line 444 def placeheld (@table_names+allfields[1]+conditions).collect{|x| x.placeheld}.flatten end |
#to_s ⇒ Object
438 439 440 441 442 |
# File 'lib/sql/statement.rb', line 438 def to_s statement="UPDATE #{tables_s} SET #{updatepart_s}" v=conditions_s; statement << " WHERE "<< v if v statement end |