Class: Mysql2::Statement
- Inherits:
-
Object
- Object
- Mysql2::Statement
- Defined in:
- lib/mysql2/statement.rb
Instance Method Summary collapse
- #affected_rows ⇒ Object
- #close ⇒ Object
- #execute(*args, **opts) ⇒ Object
- #field_count ⇒ Object
- #fields ⇒ Object
-
#initialize(stmt, **opts) ⇒ Statement
constructor
A new instance of Statement.
- #last_id ⇒ Object
- #param_count ⇒ Object
Constructor Details
#initialize(stmt, **opts) ⇒ Statement
Returns a new instance of Statement.
4 5 6 7 |
# File 'lib/mysql2/statement.rb', line 4 def initialize(stmt, **opts) @stmt = stmt @opts = opts end |
Instance Method Details
#affected_rows ⇒ Object
29 30 31 |
# File 'lib/mysql2/statement.rb', line 29 def affected_rows @stmt.affected_rows end |
#close ⇒ Object
37 38 39 |
# File 'lib/mysql2/statement.rb', line 37 def close @stmt.close end |
#execute(*args, **opts) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/mysql2/statement.rb', line 21 def execute(*args, **opts) res = @stmt.execute(*args, **opts) opts = @opts.merge(opts) StatementResult.new(res, **opts) rescue Mysql::Error => e raise Mysql2::Error, e. end |
#field_count ⇒ Object
13 14 15 |
# File 'lib/mysql2/statement.rb', line 13 def field_count @stmt.field_count end |
#fields ⇒ Object
17 18 19 |
# File 'lib/mysql2/statement.rb', line 17 def fields field_count == 0 ? nil : @stmt.fields.map(&:name) end |
#last_id ⇒ Object
33 34 35 |
# File 'lib/mysql2/statement.rb', line 33 def last_id @stmt.insert_id end |
#param_count ⇒ Object
9 10 11 |
# File 'lib/mysql2/statement.rb', line 9 def param_count @stmt.param_count end |