module ActiveRecord::ConnectionAdapters::MySQL::DatabaseStatements
Public Instance Methods
# File activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb, line 62 def exec_delete(sql, name = nil, binds = []) if without_prepared_statement?(binds) @lock.synchronize do execute_and_free(sql, name) { @connection.affected_rows } end else exec_stmt_and_free(sql, name, binds) { |stmt| stmt.affected_rows } end end
Also aliased as: exec_update
# File activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb, line 42 def exec_query(sql, name = "SQL", binds = [], prepare: false) if without_prepared_statement?(binds) execute_and_free(sql, name) do |result| if result ActiveRecord::Result.new(result.fields, result.to_a) else ActiveRecord::Result.new([], []) end end else exec_stmt_and_free(sql, name, binds, cache_stmt: prepare) do |_, result| if result ActiveRecord::Result.new(result.fields, result.to_a) else ActiveRecord::Result.new([], []) end end end end
exec_update(sql, name = nil, binds = [])
Alias for: exec_delete
# File activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb, line 30 def execute(sql, name = nil) if preventing_writes? && write_query?(sql) raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}" end # make sure we carry over any changes to ActiveRecord::Base.default_timezone that have been # made since we established the connection @connection.query_options[:database_timezone] = ActiveRecord::Base.default_timezone super end
Executes the SQL statement in the context of this connection.
Calls superclass method
© 2004–2019 David Heinemeier Hansson
Licensed under the MIT License.